in apache-rat-core/src/main/java/org/apache/rat/commandline/Arg.java [693:768]
private static void processInputArgs(final ArgumentContext context) throws ConfigurationException {
try {
if (SOURCE.isSelected()) {
File[] files = SOURCE.getParsedOptionValues(context.getCommandLine());
for (File f : files) {
context.getConfiguration().addSource(f);
}
}
// TODO when include/exclude processing is updated check calling methods to ensure that all specified
// directories are handled in the list of directories.
if (EXCLUDE.isSelected()) {
String[] excludes = context.getCommandLine().getOptionValues(EXCLUDE.getSelected());
if (excludes != null) {
context.getConfiguration().addExcludedPatterns(Arrays.asList(excludes));
}
}
if (EXCLUDE_FILE.isSelected()) {
File excludeFileName = context.getCommandLine().getParsedOptionValue(EXCLUDE_FILE.getSelected());
if (excludeFileName != null) {
context.getConfiguration().addExcludedPatterns(ExclusionUtils.asIterable(excludeFileName, "#"));
}
}
if (EXCLUDE_STD.isSelected()) {
for (String s : context.getCommandLine().getOptionValues(EXCLUDE_STD.getSelected())) {
context.getConfiguration().addExcludedCollection(StandardCollection.valueOf(s));
}
}
if (EXCLUDE_PARSE_SCM.isSelected()) {
StandardCollection[] collections = EXCLUDE_PARSE_SCM.getParsedOptionValues(context.getCommandLine());
final ReportConfiguration configuration = context.getConfiguration();
for (StandardCollection collection : collections) {
if (collection == StandardCollection.ALL) {
Arrays.asList(StandardCollection.values()).forEach(configuration::addExcludedFileProcessor);
Arrays.asList(StandardCollection.values()).forEach(configuration::addExcludedCollection);
} else {
configuration.addExcludedFileProcessor(collection);
configuration.addExcludedCollection(collection);
}
}
}
if (EXCLUDE_SIZE.isSelected()) {
final int maxSize = EXCLUDE_SIZE.getParsedOptionValue(context.getCommandLine());
DocumentNameMatcher matcher = new DocumentNameMatcher(String.format("File size < %s bytes", maxSize),
(Predicate<DocumentName>) documentName -> {
File f = new File(documentName.getName());
return f.isFile() && f.length() < maxSize;
});
context.getConfiguration().addExcludedMatcher(matcher);
}
if (INCLUDE.isSelected()) {
String[] includes = context.getCommandLine().getOptionValues(INCLUDE.getSelected());
if (includes != null) {
context.getConfiguration().addIncludedPatterns(Arrays.asList(includes));
}
}
if (INCLUDE_FILE.isSelected()) {
File includeFileName = context.getCommandLine().getParsedOptionValue(INCLUDE_FILE.getSelected());
if (includeFileName != null) {
context.getConfiguration().addIncludedPatterns(ExclusionUtils.asIterable(includeFileName, "#"));
}
}
if (INCLUDE_STD.isSelected()) {
Option selected = INCLUDE_STD.getSelected();
// display deprecation log if needed.
if (context.getCommandLine().hasOption("scan-hidden-directories")) {
context.getConfiguration().addIncludedCollection(StandardCollection.HIDDEN_DIR);
} else {
for (String s : context.getCommandLine().getOptionValues(selected)) {
context.getConfiguration().addIncludedCollection(StandardCollection.valueOf(s));
}
}
}
} catch (Exception e) {
throw ConfigurationException.from(e);
}
}