Update to filter *.json files.
diff --git a/apache-rat-core/src/main/java/org/apache/rat/Defaults.java b/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
index cb747f0..eec4b47 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
@@ -19,6 +19,7 @@
package org.apache.rat;
import java.io.File;
+import java.io.FilenameFilter;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -28,6 +29,9 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import org.apache.commons.io.IOCase;
+import org.apache.commons.io.filefilter.IOFileFilter;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.io.function.IOSupplier;
import org.apache.rat.configuration.Format;
import org.apache.rat.configuration.LicenseReader;
@@ -37,6 +41,7 @@
import org.apache.rat.license.LicenseSetFactory;
import org.apache.rat.license.LicenseSetFactory.LicenseFilter;
import org.apache.rat.utils.Log;
+import org.apache.rat.walker.NameBasedHiddenFileFilter;
/**
* A class that holds the list of licenses and approved licenses from one or more configuration files.
@@ -57,6 +62,10 @@
public static final String UNAPPROVED_LICENSES_STYLESHEET = "org/apache/rat/unapproved-licenses.xsl";
private final LicenseSetFactory setFactory;
+
+ private final FilenameFilter filesToIgnore = WildcardFileFilter.builder().setWildcards("*.json").setIoCase(IOCase.INSENSITIVE).get();
+
+ private final IOFileFilter directoriesToIgnore = NameBasedHiddenFileFilter.HIDDEN;
/**
* Initialize the system configuration reader..
@@ -155,6 +164,14 @@
public SortedSet<String> getLicenseIds(LicenseFilter filter) {
return setFactory.getLicenseFamilyIds(filter);
}
+
+ public FilenameFilter getFilesToIgnore() {
+ return filesToIgnore;
+ }
+
+ public IOFileFilter getDirectoriesToIgnore() {
+ return directoriesToIgnore;
+ }
/**
* The Defaults builder.
diff --git a/apache-rat-core/src/main/java/org/apache/rat/Report.java b/apache-rat-core/src/main/java/org/apache/rat/Report.java
index 6f49556..74ba5d1 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/Report.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/Report.java
@@ -238,7 +238,7 @@
}
if (cl.hasOption(SCAN_HIDDEN_DIRECTORIES)) {
- configuration.setDirectoryFilter(null);
+ configuration.setDirectoriesToIgnore(null);
}
if (cl.hasOption('a') || cl.hasOption('A')) {
@@ -250,14 +250,14 @@
String[] excludes = cl.getOptionValues(EXCLUDE_CLI);
if (excludes != null) {
final FilenameFilter filter = parseExclusions(Arrays.asList(excludes));
- configuration.setInputFileFilter(filter);
+ configuration.setFilesToIgnore(filter);
}
} else if (cl.hasOption(EXCLUDE_FILE_CLI)) {
String excludeFileName = cl.getOptionValue(EXCLUDE_FILE_CLI);
if (excludeFileName != null) {
final FilenameFilter filter = parseExclusions(
FileUtils.readLines(new File(excludeFileName), StandardCharsets.UTF_8));
- configuration.setInputFileFilter(filter);
+ configuration.setFilesToIgnore(filter);
}
}
@@ -452,11 +452,11 @@
}
if (base.isDirectory()) {
- return new DirectoryWalker(base, config.getInputFileFilter(), config.getDirectoryFilter());
+ return new DirectoryWalker(base, config.getFilesToIgnore(), config.getDirectoriesToIgnore());
}
try {
- return new ArchiveWalker(base, config.getInputFileFilter());
+ return new ArchiveWalker(base, config.getFilesToIgnore());
} catch (IOException ex) {
config.getLog().log(Level.ERROR, "file '"+baseDirectory+"' is not valid gzip data.");
return null;
diff --git a/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java b/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
index d737989..339cb5a 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
@@ -50,7 +50,6 @@
import org.apache.rat.report.IReportable;
import org.apache.rat.utils.Log;
import org.apache.rat.utils.ReportingSet;
-import org.apache.rat.walker.NameBasedHiddenFileFilter;
/**
* A configuration object is used by the front end to invoke the
@@ -69,9 +68,9 @@
private boolean styleReport;
private IOSupplier<InputStream> styleSheet;
private IReportable reportable;
- private FilenameFilter inputFileFilter;
- private IOFileFilter directoryFilter;
- private Log log;
+ private FilenameFilter filesToIgnore;
+ private IOFileFilter directoriesToIgnore;
+ private final Log log;
private LicenseFilter listFamilies;
private LicenseFilter listLicenses;
private boolean dryRun;
@@ -89,7 +88,6 @@
.setMsgFormat( s -> String.format( "Duplicate License %s (%s) of type %s", s.getName(), s.getId(), s.getLicenseFamily().getFamilyCategory()));
approvedLicenseCategories = new TreeSet<>();
removedLicenseCategories = new TreeSet<>();
- directoryFilter = NameBasedHiddenFileFilter.HIDDEN;
styleReport = true;
listFamilies = LicenseFilter.NONE;
listLicenses = LicenseFilter.NONE;
@@ -179,31 +177,31 @@
/**
* @return The filename filter for the potential input files.
*/
- public FilenameFilter getInputFileFilter() {
- return inputFileFilter;
+ public FilenameFilter getFilesToIgnore() {
+ return filesToIgnore;
}
/**
- * @param inputFileFilter the filename filter to filter the input files.
+ * @param filesToIgnore the filename filter to filter the input files.
*/
- public void setInputFileFilter(FilenameFilter inputFileFilter) {
- this.inputFileFilter = inputFileFilter;
+ public void setFilesToIgnore(FilenameFilter filesToIgnore) {
+ this.filesToIgnore = filesToIgnore;
}
- public IOFileFilter getDirectoryFilter() {
- return directoryFilter;
+ public IOFileFilter getDirectoriesToIgnore() {
+ return directoriesToIgnore;
}
- public void setDirectoryFilter(IOFileFilter directoryFilter) {
- if (directoryFilter == null) {
- this.directoryFilter = FalseFileFilter.FALSE;
+ public void setDirectoriesToIgnore(IOFileFilter directoriesToIgnore) {
+ if (directoriesToIgnore == null) {
+ this.directoriesToIgnore = FalseFileFilter.FALSE;
} else {
- this.directoryFilter = directoryFilter;
+ this.directoriesToIgnore = directoriesToIgnore;
}
}
- public void addDirectoryFilter(IOFileFilter directoryFilter) {
- this.directoryFilter = this.directoryFilter.and(directoryFilter);
+ public void addDirectoryToIgnore(IOFileFilter directoryToIgnore) {
+ this.directoriesToIgnore = this.directoriesToIgnore.and(directoryToIgnore);
}
/**
@@ -247,6 +245,8 @@
* @param defaults The defaults to set.
*/
public void setFrom(Defaults defaults) {
+ setFilesToIgnore(defaults.getFilesToIgnore());
+ setDirectoriesToIgnore(defaults.getDirectoriesToIgnore());
addLicensesIfNotPresent(defaults.getLicenses(LicenseFilter.ALL));
addApprovedLicenseCategories(defaults.getLicenseIds(LicenseFilter.APPROVED));
if (isStyleReport() && getStyleSheet() == null) {
diff --git a/apache-rat-core/src/main/java/org/apache/rat/analysis/DefaultAnalyserFactory.java b/apache-rat-core/src/main/java/org/apache/rat/analysis/DefaultAnalyserFactory.java
index e60b95c..131cc68 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/analysis/DefaultAnalyserFactory.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/analysis/DefaultAnalyserFactory.java
@@ -71,7 +71,7 @@
/**
* Constructs a DocumentAnalyser for the specified license.
- *
+ * @param log the Log to use
* @param license The license to analyse
*/
public DefaultAnalyser(final Log log, final Collection<ILicense> licenses) {
diff --git a/apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimStatistic.java b/apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimStatistic.java
index 3f08d7f..c367962 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimStatistic.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimStatistic.java
@@ -19,8 +19,10 @@
package org.apache.rat.report.claim;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import org.apache.rat.api.Document;
@@ -39,12 +41,12 @@
/** count of generated files */
GENERATED,
/** count of unknown files */
- UNKNOWN };
+ UNKNOWN }
- private final Map<String, int[]> licenseFamilyNameMap = new HashMap<>();
- private final Map<String, int[]> licenseFamilyCodeMap = new HashMap<>();
- private final Map<Document.Type, int[]> documentCategoryMap = new HashMap<>();
- private final Map<ClaimStatistic.Counter, int[]> counterMap = new HashMap<>();
+ protected final Map<String, int[]> licenseFamilyNameMap = new HashMap<>();
+ protected final Map<String, int[]> licenseFamilyCodeMap = new HashMap<>();
+ protected final Map<Document.Type, int[]> documentCategoryMap = new HashMap<>();
+ protected final Map<ClaimStatistic.Counter, int[]> counterMap = new HashMap<>();
/**
@@ -57,45 +59,108 @@
return count == null ? 0 : count[0];
}
- /**
- * @return Returns a map with the file types. The map keys
- * are file type names and the map values
- * are integers with the number of resources matching
- * the file type.
- */
- public Map<Counter, int[]> getCounterMap() {
- return counterMap;
+ public void incCounter(Counter key, int value) {
+ final int[] num = counterMap.get(key);
+
+ if (num == null) {
+ counterMap.put(key, new int[] { value });
+ } else {
+ num[0] += value;
+ }
}
-
- /**
- * @return Returns a map with the file types. The map keys
- * are file type names and the map values
- * are integers with the number of resources matching
- * the file type.
- */
- public Map<Document.Type, int[]> getDocumentCategoryMap() {
- return documentCategoryMap;
- }
+// /**
+// * @return Returns a map with the file types. The map keys
+// * are file type names and the map values
+// * are integers with the number of resources matching
+// * the file type.
+// */
+// public Map<Counter, int[]> getCounterMap() {
+// return counterMap;
+// }
/**
- * @return Returns a map with the license family codes. The map
- * keys are license family category names,
- * the map values are integers with the number of resources
- * matching the license family code.
+ * Returns the counts for the counter.
+ * @param documentType the document type to get the counter for.
+ * @return Returns the number of files with approved licenses.
*/
- public Map<String, int[]> getLicenseFamilyCodeMap() {
- return licenseFamilyCodeMap;
+ public int getCounter(Document.Type documentType) {
+ int[] count = documentCategoryMap.get(documentType);
+ return count == null ? 0 : count[0];
}
- /**
- * @return Returns a map with the license family codes. The map
- * keys are the names of the license families and
- * the map values are integers with the number of resources
- * matching the license family name.
- */
- public Map<String, int[]> getLicenseFileNameMap() {
- return licenseFamilyNameMap;
+ public void incCounter(Document.Type documentType, int value) {
+ final int[] num = documentCategoryMap.get(documentType);
+
+ if (num == null) {
+ documentCategoryMap.put(documentType, new int[] { value });
+ } else {
+ num[0] += value;
+ }
+ }
+// /**
+// * @return Returns a map with the file types. The map keys
+// * are file type names and the map values
+// * are integers with the number of resources matching
+// * the file type.
+// */
+// public Map<Document.Type, int[]> getDocumentCategoryMap() {
+// return documentCategoryMap;
+// }
+
+// /**
+// * @return Returns a map with the license family codes. The map
+// * keys are license family category names,
+// * the map values are integers with the number of resources
+// * matching the license family code.
+// */
+// public Map<String, int[]> getLicenseFamilyCodeMap() {
+// return licenseFamilyCodeMap;
+// }
+
+ public int getLicenseFamilyCount(String licenseFamilyName) {
+ int[] count = licenseFamilyCodeMap.get(licenseFamilyName);
+ return count == null ? 0 : count[0];
}
+ public void incLicenseFamilyCount(String licenseFamilyName, int value) {
+ final int[] num = licenseFamilyCodeMap.get(licenseFamilyName);
+
+ if (num == null) {
+ licenseFamilyCodeMap.put(licenseFamilyName, new int[] { value });
+ } else {
+ num[0] += value;
+ }
+ }
+
+ public Set<String> getLicenseFamilyNames() {
+ return Collections.unmodifiableSet(licenseFamilyCodeMap.keySet());
+ }
+// /**
+// * @return Returns a map with the license family codes. The map
+// * keys are the names of the license families and
+// * the map values are integers with the number of resources
+// * matching the license family name.
+// */
+// public Map<String, int[]> getLicenseFileNameMap() {
+// return licenseFamilyNameMap;
+// }
+ public Set<String> getLicenseFileNames() {
+ return Collections.unmodifiableSet(licenseFamilyNameMap.keySet());
+ }
+
+ public int getLicenseFileNameCount(String licenseFilename) {
+ int[] count = licenseFamilyNameMap.get(licenseFilename);
+ return count == null ? 0 : count[0];
+ }
+
+ public void incLicenseFileNameCount(String licenseFileNameName, int value) {
+ final int[] num = licenseFamilyNameMap.get(licenseFileNameName);
+
+ if (num == null) {
+ licenseFamilyNameMap.put(licenseFileNameName, new int[] { value });
+ } else {
+ num[0] += value;
+ }
+ }
}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/ClaimAggregator.java b/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/ClaimAggregator.java
index 598d4a1..06c43ef 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/ClaimAggregator.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/ClaimAggregator.java
@@ -43,52 +43,31 @@
this.statistic = statistic;
}
- private <T> void incMapValue(Map<T, int[]> map, T key, int value) {
- final int[] num = map.get(key);
-
- if (num == null) {
- map.put(key, new int[] { value });
- } else {
- num[0] += value;
- }
- }
-
@Override
protected void handleDocumentCategoryClaim(Document.Type documentType) {
- incMapValue(statistic.getDocumentCategoryMap(), documentType, 1);
+ statistic.incCounter(documentType, 1);
}
@Override
protected void handleApprovedLicenseClaim(MetaData metadata) {
- incValueMap(statistic.getCounterMap(), ClaimStatistic.Counter.APPROVED, (int) metadata.approvedLicenses().count());
- incValueMap(statistic.getCounterMap(), ClaimStatistic.Counter.UNAPPROVED,
- (int) metadata.unapprovedLicenses().count());
- }
-
- private void incValueMap(Map<Counter, int[]> map, Counter key, int value) {
- final int[] num = map.get(key);
-
- if (num == null) {
- map.put(key, new int[] { value });
- } else {
- num[0] += value;
- }
+ statistic.incCounter(ClaimStatistic.Counter.APPROVED, (int) metadata.approvedLicenses().count());
+ statistic.incCounter(ClaimStatistic.Counter.UNAPPROVED, (int) metadata.unapprovedLicenses().count());
}
@Override
protected void handleLicenseFamilyNameClaim(String licenseFamilyName) {
- incMapValue(statistic.getLicenseFileNameMap(), licenseFamilyName, 1);
+ statistic.incLicenseFileNameCount(licenseFamilyName, 1);
}
@Override
protected void handleHeaderCategoryClaim(ILicense license) {
String category = license.getLicenseFamily().getFamilyCategory();
if (category.equals(ILicenseFamily.GENTERATED_CATEGORY)) {
- incValueMap(statistic.getCounterMap(), Counter.GENERATED, 1);
+ statistic.incCounter(Counter.GENERATED, 1);
} else if (category.equals(ILicenseFamily.UNKNOWN_CATEGORY)) {
- incValueMap(statistic.getCounterMap(), Counter.UNKNOWN, 1);
+ statistic.incCounter(Counter.UNKNOWN, 1);
}
- incMapValue(statistic.getLicenseFamilyCodeMap(), category, 1);
+ statistic.getLicenseFamilyCount(category);
}
@Override
diff --git a/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java b/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
index ab75cd3..7465f63 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
@@ -22,8 +22,11 @@
import java.io.File;
import java.io.FilenameFilter;
import java.util.Arrays;
+import java.util.Objects;
+import java.util.function.Predicate;
import java.util.regex.Pattern;
+import org.apache.commons.io.filefilter.FalseFileFilter;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.rat.api.Document;
import org.apache.rat.api.RatException;
@@ -38,29 +41,19 @@
private static final FileNameComparator COMPARATOR = new FileNameComparator();
- private final IOFileFilter directoryFilter;
-
- /**
- * Constructs a walker.
- *
- * @param file the directory to walk.
- * @param directoryFilter directory filter to eventually exclude some directories/files from the scan.
- */
- public DirectoryWalker(File file, IOFileFilter directoryFilter) {
- this(file, (FilenameFilter) null, directoryFilter);
- }
+ private final IOFileFilter directoriesToIgnore;
/**
* Constructs a walker.
*
* @param file the directory to walk (not null).
- * @param filter filters input files (optional),
+ * @param filesToIgnore filters input files (optional),
* or null when no filtering should be performed
- * @param directoryFilter filters directories (optional), or null when no filtering should be performed.
+ * @param directoriesToIgnore filters directories (optional), or null when no filtering should be performed.
*/
- public DirectoryWalker(File file, final FilenameFilter filter, IOFileFilter directoryFilter) {
- super(file.getPath(), file, filter);
- this.directoryFilter = directoryFilter;
+ public DirectoryWalker(File file, final FilenameFilter filesToIgnore, IOFileFilter directoriesToIgnore) {
+ super(file.getPath(), file, filesToIgnore);
+ this.directoriesToIgnore = directoriesToIgnore == null ? FalseFileFilter.FALSE : directoriesToIgnore;
}
/**
@@ -68,11 +61,11 @@
*
* @param file the directory to walk (not null).
* @param ignoreNameRegex ignore directories/files with name matching the regex.
- * @param directoryFilter filters directories (optional), or null when no filtering should be performed.
+ * @param directoriesToIgnore filters directories (optional), or null when no filtering should be performed.
*/
- public DirectoryWalker(File file, final Pattern ignoreNameRegex, IOFileFilter directoryFilter) {
+ public DirectoryWalker(File file, final Pattern ignoreNameRegex, IOFileFilter directoriesToIgnore) {
super(file.getPath(), file, regexFilter(ignoreNameRegex));
- this.directoryFilter = directoryFilter;
+ this.directoriesToIgnore = directoriesToIgnore == null ? FalseFileFilter.FALSE : directoriesToIgnore;
}
/**
@@ -80,14 +73,10 @@
*
* @param report The report to process the directory with
* @param file the directory to process
- * @throws RatException
+ * @throws RatException on error.
*/
private void processDirectory(RatReport report, final File file) throws RatException {
- if (directoryFilter != null) {
- if (!directoryFilter.accept(file)) {
- process(report, file);
- }
- } else {
+ if (!directoriesToIgnore.accept(file)) {
process(report, file);
}
}
@@ -97,6 +86,7 @@
* ignoring any files/directories set to be ignored.
*
* @param report the defined RatReport to run on this Directory walker.
+ * @throws RatException on error
*/
public void run(final RatReport report) throws RatException {
process(report, file);
@@ -107,7 +97,7 @@
*
* @param report the report to use in processing
* @param file the run the report against
- * @throws RatException
+ * @throws RatException on error
*/
private void process(final RatReport report, final File file) throws RatException {
final File[] files = file.listFiles();
@@ -124,11 +114,11 @@
*
* @param report the report to use in processing
* @param files the files to process (only directories will be processed)
- * @throws RatException
+ * @throws RatException on error
*/
private void processDirectories(final RatReport report, final File[] files) throws RatException {
for (final File file : files) {
- if (isNotIgnored(file) && file.isDirectory()) {
+ if (file.isDirectory() && isNotIgnored(file)) {
processDirectory(report, file);
}
}
@@ -139,28 +129,13 @@
*
* @param report the report to use in processing
* @param files the files to process (only files will be processed)
- * @throws RatException
+ * @throws RatException on error
*/
private void processNonDirectories(final RatReport report, final File[] files) throws RatException {
for (final File file : files) {
- if (isNotIgnored(file) && !file.isDirectory()) {
- report(report, file);
+ if (!file.isDirectory() && isNotIgnored(file)) {
+ report.report(new FileDocument(file));
}
}
-
- }
-
- /**
- * Report on the given file.
- *
- * @param report the report to process the file with
- * @param file the file to be reported on
- * @throws RatException
- */
- private void report(final RatReport report, File file) throws RatException {
-
- Document document = new FileDocument(file);
- report.report(document);
-
}
}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/walker/Walker.java b/apache-rat-core/src/main/java/org/apache/rat/walker/Walker.java
index daecbd1..99a5829 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/walker/Walker.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/walker/Walker.java
@@ -19,6 +19,7 @@
package org.apache.rat.walker;
+import org.apache.commons.io.filefilter.FalseFileFilter;
import org.apache.rat.report.IReportable;
import java.io.File;
@@ -33,38 +34,32 @@
protected final File file;
protected final String name;
- protected final FilenameFilter filter;
+ protected final FilenameFilter filesToIgnore;
protected static FilenameFilter regexFilter(final Pattern pattern) {
return (dir, name) -> {
final boolean result;
if (pattern == null) {
- result = true;
+ result = false;
} else {
- result = !pattern.matcher(name).matches();
+ result = pattern.matcher(name).matches();
}
return result;
};
}
protected final boolean isNotIgnored(final File file) {
- boolean result = false;
- if (filter != null) {
- final String name = file.getName();
- final File dir = file.getParentFile();
- result = !filter.accept(dir, name);
- }
- return !result;
+ return !filesToIgnore.accept(file.getParentFile(), file.getName());
}
public Walker(File file, final FilenameFilter filter) {
this(file.getPath(), file, filter);
}
- protected Walker(final String name, final File file, final FilenameFilter filter) {
+ protected Walker(final String name, final File file, final FilenameFilter filesToIgnore) {
this.name = name;
this.file = file;
- this.filter = filter;
+ this.filesToIgnore = filesToIgnore == null ? FalseFileFilter.FALSE : filesToIgnore;
}
}
diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReportConfigurationTest.java b/apache-rat-core/src/test/java/org/apache/rat/ReportConfigurationTest.java
index 9325602..96cd894 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReportConfigurationTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReportConfigurationTest.java
@@ -22,6 +22,7 @@
import static org.assertj.core.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
@@ -44,9 +45,11 @@
import java.util.SortedSet;
import java.util.function.Function;
+import org.apache.commons.io.IOCase;
import org.apache.commons.io.filefilter.AndFileFilter;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.commons.io.filefilter.FalseFileFilter;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.io.function.IOSupplier;
import org.apache.rat.ReportConfiguration.NoCloseOutputStream;
import org.apache.rat.analysis.IHeaderMatcher;
@@ -57,6 +60,7 @@
import org.apache.rat.license.LicenseSetFactory.LicenseFilter;
import org.apache.rat.report.IReportable;
import org.apache.rat.testhelpers.TestingLicense;
+import org.apache.rat.utils.DefaultLog;
import org.apache.rat.utils.Log;
import org.apache.rat.utils.Log.Level;
import org.apache.rat.utils.ReportingSet.Options;
@@ -186,24 +190,33 @@
}
@Test
- public void inputFileFilterTest() {
+ public void filesToIgnoreTest() {
+
+ assertThat(underTest.getFilesToIgnore()).isNull();
+
+ underTest.setFrom(Defaults.builder().build(DefaultLog.INSTANCE));
+ assertThat(underTest.getFilesToIgnore()).isNotNull();
+ assertThat(underTest.getFilesToIgnore()).isExactlyInstanceOf(WildcardFileFilter.class);
+
FilenameFilter filter = mock(FilenameFilter.class);
- assertThat(underTest.getInputFileFilter()).isNull();
- underTest.setInputFileFilter(filter);
- assertThat(underTest.getInputFileFilter()).isEqualTo(filter);
+ underTest.setFilesToIgnore(filter);
+ assertThat(underTest.getFilesToIgnore()).isEqualTo(filter);
}
@Test
- public void directoryFilterTest() {
- assertThat(underTest.getDirectoryFilter()).isNotNull();
- assertThat(underTest.getDirectoryFilter()).isExactlyInstanceOf(NameBasedHiddenFileFilter.class);
+ public void directoriesToIgnoreTest() {
+ assertThat(underTest.getDirectoriesToIgnore()).isNull();
- underTest.setDirectoryFilter(DirectoryFileFilter.DIRECTORY);
- underTest.addDirectoryFilter(NameBasedHiddenFileFilter.HIDDEN);
- assertThat(underTest.getDirectoryFilter()).isExactlyInstanceOf(AndFileFilter.class);
+ underTest.setFrom(Defaults.builder().build(DefaultLog.INSTANCE));
+ assertThat(underTest.getDirectoriesToIgnore()).isNotNull();
+ assertThat(underTest.getDirectoriesToIgnore()).isExactlyInstanceOf(NameBasedHiddenFileFilter.class);
- underTest.setDirectoryFilter(null);
- assertThat(underTest.getDirectoryFilter()).isExactlyInstanceOf(FalseFileFilter.class);
+ underTest.setDirectoriesToIgnore(DirectoryFileFilter.DIRECTORY);
+ underTest.addDirectoryToIgnore(NameBasedHiddenFileFilter.HIDDEN);
+ assertThat(underTest.getDirectoriesToIgnore()).isExactlyInstanceOf(AndFileFilter.class);
+
+ underTest.setDirectoriesToIgnore(null);
+ assertThat(underTest.getDirectoriesToIgnore()).isExactlyInstanceOf(FalseFileFilter.class);
}
@Test
@@ -549,11 +562,11 @@
assertThat(config.isAddingLicenses()).isFalse();
assertThat(config.isAddingLicensesForced()).isFalse();
assertThat(config.getCopyrightMessage()).isNull();
- assertThat(config.getInputFileFilter()).isNull();
+ assertThat(config.getFilesToIgnore().toString()).isEqualTo(WildcardFileFilter.builder().setWildcards("*.json").setIoCase(IOCase.INSENSITIVE).get().toString());
assertThat(config.isStyleReport()).isTrue();
assertThat(config.getStyleSheet()).isNotNull().withFailMessage("Stylesheet should not be null");
- assertThat(config.getDirectoryFilter()).isNotNull().withFailMessage("Directory filter should not be null");
- assertThat(config.getDirectoryFilter()).isExactlyInstanceOf(NameBasedHiddenFileFilter.class);
+ assertThat(config.getDirectoriesToIgnore()).isNotNull().withFailMessage("Directory filter should not be null");
+ assertThat(config.getDirectoriesToIgnore()).isExactlyInstanceOf(NameBasedHiddenFileFilter.class);
validateDefaultApprovedLicenses(config);
validateDefaultLicenseFamilies(config);
diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java b/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
index 0b77ec1..acd5302 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
@@ -71,7 +71,7 @@
new Reporter(config).output();
assertTrue(output.exists());
String content = FileUtils.readFileToString(output, StandardCharsets.UTF_8);
- assertTrue(content.contains("3 Unknown Licenses"));
+ assertTrue(content.contains("2 Unknown Licenses"));
assertTrue(content.contains("target/test-classes/elements/Source.java"));
assertTrue(content.contains("target/test-classes/elements/sub/Empty.txt"));
}
@@ -94,10 +94,10 @@
TextUtils.assertPatternInOutput("Notes: 2$", content);
TextUtils.assertPatternInOutput("Binaries: 1$", content);
TextUtils.assertPatternInOutput("Archives: 1$", content);
- TextUtils.assertPatternInOutput("Standards: 9$", content);
+ TextUtils.assertPatternInOutput("Standards: 8$", content);
TextUtils.assertPatternInOutput("Apache Licensed: 5$", content);
TextUtils.assertPatternInOutput("Generated Documents: 1$", content);
- TextUtils.assertPatternInOutput("^3 Unknown Licenses", content);
+ TextUtils.assertPatternInOutput("^2 Unknown Licenses", content);
assertTrue(content.contains(" S target/test-classes/elements/ILoggerFactory.java"));
assertTrue(content.contains(" B target/test-classes/elements/Image.png"));
assertTrue(content.contains(" N target/test-classes/elements/LICENSE"));
@@ -108,7 +108,6 @@
assertTrue(content.contains(" S target/test-classes/elements/Xml.xml"));
assertTrue(content.contains(" S target/test-classes/elements/buildr.rb"));
assertTrue(content.contains(" A target/test-classes/elements/dummy.jar"));
- assertTrue(content.contains("!S target/test-classes/elements/plain.json"));
assertTrue(content.contains("!S target/test-classes/elements/sub/Empty.txt"));
assertTrue(content.contains(" S target/test-classes/elements/tri.txt"));
assertTrue(content.contains(" G target/test-classes/elements/generated.txt"));
@@ -132,7 +131,7 @@
XPath xPath = XPathFactory.newInstance().newXPath();
NodeList nodeList = XmlUtils.getNodeList(doc, xPath, "/rat-report/resource/license[@approval='false']");
- assertEquals(3, nodeList.getLength());
+ assertEquals(2, nodeList.getLength());
nodeList = XmlUtils.getNodeList(doc, xPath, "/rat-report/resource/license[@id='AL']");
assertEquals(5, nodeList.getLength());
@@ -147,11 +146,11 @@
assertEquals(1, nodeList.getLength());
nodeList = XmlUtils.getNodeList(doc, xPath, "/rat-report/resource/license[@id='?????']");
- assertEquals(3, nodeList.getLength());
+ assertEquals(2, nodeList.getLength());
// GENERATED, UNKNOWN, ARCHIVE, NOTICE, BINARY, STANDARD
nodeList = XmlUtils.getNodeList(doc, xPath, "/rat-report/resource[@type='STANDARD']");
- assertEquals(9, nodeList.getLength());
+ assertEquals(8, nodeList.getLength());
nodeList = XmlUtils.getNodeList(doc, xPath, "/rat-report/resource[@type='ARCHIVE']");
assertEquals(1, nodeList.getLength());
@@ -169,7 +168,7 @@
assertEquals(2, nodeList.getLength());
nodeList = XmlUtils.getNodeList(doc, xPath, "/rat-report/resource/sample");
- assertEquals(2, nodeList.getLength());
+ assertEquals(1, nodeList.getLength());
nodeList = XmlUtils.getNodeList(doc, xPath, "/rat-report/resource[@type='GENERATED']/license/notes");
assertEquals(1, nodeList.getLength());
diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java b/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
index c95fbfb..f1b26a3 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
@@ -53,12 +53,12 @@
* @param doc The document to check/
* @param xpath the XPath instance to use.
* @param resource the xpath statement to locate the node.
- * @param id the expected family for the node (may be null)
- * @param approval the expected approval value (may be null)
+ * @param licenseInfo the license info for the node. (may = null)
* @param type the type of resource located.
+ * @param hasSample true if a sample from the document should be present.
* @throws Exception on XPath error.
*/
- public static void checkNode(Document doc, XPath xpath, String resource, LicenseInfo licenseInfo, String type,
+ private static void checkNode(Document doc, XPath xpath, String resource, LicenseInfo licenseInfo, String type,
boolean hasSample) throws Exception {
XmlUtils.getNode(doc, xpath, String.format("/rat-report/resource[@name='%s'][@type='%s']", resource, type));
if (licenseInfo != null) {
@@ -67,7 +67,7 @@
resource, type, licenseInfo.id, licenseInfo.family));
XmlUtils.getNode(doc, xpath,
String.format("/rat-report/resource[@name='%s'][@type='%s']/license[@id='%s'][@approval='%s']",
- resource, type, licenseInfo.id, Boolean.toString(licenseInfo.approval)));
+ resource, type, licenseInfo.id, licenseInfo.approval));
if (licenseInfo.hasNotes) {
XmlUtils.getNode(doc, xpath,
String.format("/rat-report/resource[@name='%s'][@type='%s']/license[@id='%s']/notes", resource,
@@ -89,7 +89,7 @@
final ReportConfiguration configuration = new ReportConfiguration(DefaultLog.INSTANCE);
configuration.setStyleReport(false);
configuration.setFrom(defaults);
- configuration.setReportable(new DirectoryWalker(new File(elementsPath), HiddenFileFilter.HIDDEN));
+ configuration.setReportable(new DirectoryWalker(new File(elementsPath), configuration.getFilesToIgnore(), HiddenFileFilter.HIDDEN));
configuration.setOut(() -> out);
new Reporter(configuration).output();
Document doc = XmlUtils.toDom(new ByteArrayInputStream(out.toByteArray()));
@@ -111,7 +111,6 @@
checkNode(doc, xPath, "src/test/resources/elements/Xml.xml", apacheLic, "STANDARD", false);
checkNode(doc, xPath, "src/test/resources/elements/buildr.rb", apacheLic, "STANDARD", false);
checkNode(doc, xPath, "src/test/resources/elements/dummy.jar", null, "ARCHIVE", false);
- checkNode(doc, xPath, "src/test/resources/elements/plain.json", null, "STANDARD", false);
checkNode(doc, xPath, "src/test/resources/elements/sub/Empty.txt", new LicenseInfo("?????", false, false),
"STANDARD", false);
checkNode(doc, xPath, "src/test/resources/elements/tri.txt", apacheLic, "STANDARD", false);
@@ -122,10 +121,10 @@
checkNode(doc, xPath, "src/test/resources/elements/generated.txt", new LicenseInfo("GEN", true, true),
"GENERATED", false);
NodeList nodeList = (NodeList) xPath.compile("/rat-report/resource").evaluate(doc, XPathConstants.NODESET);
- assertEquals(14, nodeList.getLength());
+ assertEquals(13, nodeList.getLength());
}
- private static final String NL = System.getProperty("line.separator");
+ private static final String NL = System.lineSeparator();
private static final String PARAGRAPH = "*****************************************************";
private static final String HEADER = NL + PARAGRAPH + NL + //
"Summary" + NL + //
@@ -133,7 +132,7 @@
"Generated at: ";
private String documentOut(boolean approved, Type type, String name) {
- return String.format("^\\Q%s%s %s\\E$", approved ? " " : "!", type.name().substring(0, 1), name);
+ return String.format("^\\Q%s%s %s\\E$", approved ? " " : "!", type.name().charAt(0), name);
}
private String licenseOut(String family, String name) {
@@ -152,7 +151,7 @@
final String elementsPath = Resources.getResourceDirectory("elements/Source.java");
final ReportConfiguration configuration = new ReportConfiguration(DefaultLog.INSTANCE);
configuration.setFrom(defaults);
- configuration.setReportable(new DirectoryWalker(new File(elementsPath), HiddenFileFilter.HIDDEN));
+ configuration.setReportable(new DirectoryWalker(new File(elementsPath), configuration.getFilesToIgnore(), HiddenFileFilter.HIDDEN));
configuration.setOut(() -> out);
new Reporter(configuration).output();
@@ -164,14 +163,13 @@
TextUtils.assertPatternInOutput("^Notes: 2$", document);
TextUtils.assertPatternInOutput("^Binaries: 1$", document);
TextUtils.assertPatternInOutput("^Archives: 1$", document);
- TextUtils.assertPatternInOutput("^Standards: 9$", document);
+ TextUtils.assertPatternInOutput("^Standards: 8$", document);
TextUtils.assertPatternInOutput("^Apache Licensed: 5$", document);
TextUtils.assertPatternInOutput("^Generated Documents: 1$", document);
- TextUtils.assertPatternInOutput("^3 Unknown Licenses$", document);
+ TextUtils.assertPatternInOutput("^2 Unknown Licenses$", document);
TextUtils.assertPatternInOutput(
"^Files with unapproved licenses:\\s+" //
+ "\\Qsrc/test/resources/elements/Source.java\\E\\s+" //
- + "\\Qsrc/test/resources/elements/plain.json\\E\\s+" //
+ "\\Qsrc/test/resources/elements/sub/Empty.txt\\E\\s",
document);
TextUtils.assertPatternInOutput(documentOut(true, Type.ARCHIVE, "src/test/resources/elements/dummy.jar"),
@@ -195,8 +193,6 @@
+ licenseOut("AL", "Apache License Version 2.0"), document);
TextUtils.assertPatternInOutput(documentOut(true, Type.STANDARD, "src/test/resources/elements/TextHttps.txt")
+ licenseOut("AL", "Apache License Version 2.0"), document);
- TextUtils.assertPatternInOutput(documentOut(false, Type.STANDARD, "src/test/resources/elements/plain.json"),
- document);
TextUtils.assertPatternInOutput(documentOut(true, Type.STANDARD, "src/test/resources/elements/tri.txt")
+ licenseOut("AL", "Apache License Version 2.0") + licenseOut("BSD-3", "BSD 3 clause")
+ licenseOut("BSD-3", "TMF", "The Telemanagement Forum License"), document);
@@ -212,7 +208,7 @@
final String elementsPath = Resources.getResourceDirectory("elements/Source.java");
final ReportConfiguration configuration = new ReportConfiguration(DefaultLog.INSTANCE);
configuration.setFrom(defaults);
- configuration.setReportable(new DirectoryWalker(new File(elementsPath), HiddenFileFilter.HIDDEN));
+ configuration.setReportable(new DirectoryWalker(new File(elementsPath), configuration.getFilesToIgnore(), HiddenFileFilter.HIDDEN));
configuration.setOut(() -> out);
configuration.setStyleSheet(this.getClass().getResource("/org/apache/rat/unapproved-licenses.xsl"));
new Reporter(configuration).output();
@@ -226,7 +222,7 @@
TextUtils.assertPatternInOutput("\\Qsrc/test/resources/elements/sub/Empty.txt\\E", document);
}
- private class LicenseInfo {
+ private static class LicenseInfo {
String id;
String family;
boolean approval;
diff --git a/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java b/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java
index 82f48e2..939a144 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java
@@ -31,6 +31,7 @@
import org.apache.commons.io.filefilter.HiddenFileFilter;
import org.apache.rat.ConfigurationException;
+import org.apache.rat.Defaults;
import org.apache.rat.ReportConfiguration;
import org.apache.rat.api.Document;
import org.apache.rat.license.ILicense;
@@ -51,7 +52,7 @@
public class XmlReportFactoryTest {
private static final Pattern IGNORE_EMPTY = Pattern.compile(".svn|Empty.txt");
- private ILicenseFamily family = ILicenseFamily.builder().setLicenseFamilyCategory("TEST")
+ private final ILicenseFamily family = ILicenseFamily.builder().setLicenseFamilyCategory("TEST")
.setLicenseFamilyName("Testing family").build();
private StringWriter out;
@@ -71,12 +72,13 @@
@Test
public void standardReport() throws Exception {
final String elementsPath = Resources.getResourceDirectory("elements/Source.java");
-
- final TestingLicense testingLicense = new TestingLicense(new TestingMatcher(true), family);
-
- DirectoryWalker directory = new DirectoryWalker(new File(elementsPath), IGNORE_EMPTY, HiddenFileFilter.HIDDEN);
- final ClaimStatistic statistic = new ClaimStatistic();
final ReportConfiguration configuration = new ReportConfiguration(DefaultLog.INSTANCE);
+ final TestingLicense testingLicense = new TestingLicense(new TestingMatcher(true), family);
+ configuration.setFrom(Defaults.builder().build(DefaultLog.INSTANCE));
+
+ DirectoryWalker directory = new DirectoryWalker(new File(elementsPath), configuration.getFilesToIgnore(), HiddenFileFilter.HIDDEN);
+ final ClaimStatistic statistic = new ClaimStatistic();
+
configuration.addLicense(testingLicense);
RatReport report = XmlReportFactory.createStandardReport(writer, statistic, configuration);
report.startReport();
@@ -88,10 +90,10 @@
"Preamble and document element are OK");
assertTrue(XmlUtils.isWellFormedXml(output), "Is well formed");
- assertEquals(1, statistic.getDocumentCategoryMap().get(Document.Type.BINARY)[0], "Binary files");
- assertEquals(2, statistic.getDocumentCategoryMap().get(Document.Type.NOTICE)[0], "Notice files");
- assertEquals(9, statistic.getDocumentCategoryMap().get(Document.Type.STANDARD)[0], "Standard files");
- assertEquals(1, statistic.getDocumentCategoryMap().get(Document.Type.ARCHIVE)[0], "Archives");
+ assertEquals(1, statistic.getCounter(Document.Type.BINARY), "Binary files");
+ assertEquals(2, statistic.getCounter(Document.Type.NOTICE), "Notice files");
+ assertEquals(8, statistic.getCounter(Document.Type.STANDARD), "Standard files");
+ assertEquals(1, statistic.getCounter(Document.Type.ARCHIVE), "Archives");
}
@Test
diff --git a/apache-rat-core/src/test/java/org/apache/rat/walker/DirectoryWalkerTest.java b/apache-rat-core/src/test/java/org/apache/rat/walker/DirectoryWalkerTest.java
index daef24b..ff141f0 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/walker/DirectoryWalkerTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/walker/DirectoryWalkerTest.java
@@ -57,13 +57,13 @@
writer.flush();
}
- DirectoryWalker walker = new DirectoryWalker(toWalk, NameBasedHiddenFileFilter.HIDDEN);
+ DirectoryWalker walker = new DirectoryWalker(toWalk, NameBasedHiddenFileFilter.HIDDEN, null);
List<String> scanned = new ArrayList<>();
walker.run(new TestRatReport(scanned));
assertEquals(1, scanned.size());
- walker = new DirectoryWalker(toWalk, FalseFileFilter.FALSE);
+ walker = new DirectoryWalker(toWalk, FalseFileFilter.FALSE, null);
scanned = new ArrayList<>();
walker.run(new TestRatReport(scanned));
diff --git a/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java b/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
index 1a39c0c..ede646e 100644
--- a/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
+++ b/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
@@ -68,6 +68,7 @@
import org.apache.rat.mp.util.ignore.IgnoreMatcher;
import org.apache.rat.mp.util.ignore.IgnoringDirectoryScanner;
import org.apache.rat.report.IReportable;
+import org.apache.rat.walker.NameBasedHiddenFileFilter;
import org.codehaus.plexus.util.DirectoryScanner;
/**
@@ -341,11 +342,15 @@
protected ReportConfiguration getConfiguration() throws MojoExecutionException {
ReportConfiguration config = new ReportConfiguration(makeLog());
reportDeprecatedProcessing();
+ Defaults defaults = getDefaultsBuilder().build(config.getLog());
if (addDefaultLicenses) {
- config.setFrom(getDefaultsBuilder().build(config.getLog()));
+ config.setFrom(defaults);
} else {
config.setStyleSheet(Defaults.getPlainStyleSheet());
+ config.setDirectoriesToIgnore(defaults.getDirectoriesToIgnore());
+ config.setFilesToIgnore(defaults.getFilesToIgnore());
}
+
if (additionalLicenseFiles != null) {
for (String licenseFile : additionalLicenseFiles) {
try {
diff --git a/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java b/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
index bb842ed..fc8dc09 100644
--- a/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
+++ b/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
@@ -177,7 +177,7 @@
configuration.setCopyrightMessage(copyrightMessage);
}
if (scanHiddenDirectories) {
- configuration.setDirectoryFilter(null);
+ configuration.setDirectoriesToIgnore(null);
}
if (reportFile != null) {
if (!reportFile.exists()) {
diff --git a/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java b/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
index 2cdc942..c30ad13 100644
--- a/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
+++ b/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
@@ -29,6 +29,8 @@
import java.io.FileWriter;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.FalseFileFilter;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.rat.ReportConfiguration;
import org.apache.rat.ReportConfigurationTest;
import org.apache.rat.api.Document;
@@ -200,7 +202,10 @@
ReportConfigurationTest.validateDefaultLicenses(config, "MyLicense", "CpyrT", "RegxT", "SpdxT", "TextT",
"Not", "All", "Any");
assertNotNull(LicenseSetFactory.search("MyLicense", config.getLicenses(LicenseFilter.ALL)));
- assertNull("Should not have inputFileFilter", config.getInputFileFilter());
+ assertNotNull("Should have filesToIgnore", config.getFilesToIgnore());
+ assertEquals("WildcardFileFilter(*.json)", config.getFilesToIgnore().toString());
+ assertNotNull("Should have directoriesToIgnore", config.getDirectoriesToIgnore());
+ assertEquals("NameBasedHiddenFileFilter", config.getDirectoriesToIgnore().toString());
mojo.execute();
ensureRatReportIsCorrect(ratTxtFile, expected, TextUtils.EMPTY);
@@ -228,11 +233,12 @@
assertThat(config.isAddingLicenses()).isFalse();
assertThat(config.isAddingLicensesForced()).isFalse();
assertThat(config.getCopyrightMessage()).isNull();
- assertThat(config.getInputFileFilter()).isNull();
assertThat(config.isStyleReport()).isTrue();
- assertThat(config.getStyleSheet()).isNotNull().withFailMessage("Stylesheet should not be null");
- assertThat(config.getDirectoryFilter()).isNotNull().withFailMessage("Directory filter should not be null");
- assertThat(config.getDirectoryFilter()).isExactlyInstanceOf(NameBasedHiddenFileFilter.class);
+ assertThat(config.getStyleSheet()).withFailMessage("Stylesheet should not be null").isNotNull();
+ assertThat(config.getDirectoriesToIgnore()).withFailMessage("directoriesToIgnore filter should not be null").isNotNull();
+ assertThat(config.getDirectoriesToIgnore()).isExactlyInstanceOf(NameBasedHiddenFileFilter.class);
+ assertThat(config.getFilesToIgnore()).withFailMessage("filesToIgnore filter should not be null").isNotNull();
+ assertThat(config.getFilesToIgnore()).isExactlyInstanceOf(WildcardFileFilter.class);
ReportConfigurationTest.validateDefaultApprovedLicenses(config, 1);
ReportConfigurationTest.validateDefaultLicenseFamilies(config, "BSD", "CC BY");
diff --git a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
index 289b04c..e7108dd 100644
--- a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
+++ b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
@@ -95,7 +95,7 @@
}
public void setInputFileFilter(FilenameFilter inputFileFilter) {
- configuration.setInputFileFilter(inputFileFilter);
+ configuration.setFilesToIgnore(inputFileFilter);
}
public void setReportFile(File reportFile) {