in apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java [461:551]
protected ReportConfiguration getConfiguration() throws MojoExecutionException {
Log log = DefaultLog.getInstance();
if (reportConfiguration == null) {
try {
if (super.getLog().isDebugEnabled()) {
log.debug("Start BaseRatMojo Configuration options");
for (Map.Entry<String, List<String>> entry : args.entrySet()) {
log.debug(format(" * %s %s", entry.getKey(), String.join(", ", entry.getValue())));
}
log.debug("End BaseRatMojo Configuration options");
}
boolean helpLicenses = !getValues(Arg.HELP_LICENSES).isEmpty();
removeKey(Arg.HELP_LICENSES);
setIncludeExclude();
getLog().warn("Basedir is : " + basedir);
ReportConfiguration config = OptionCollection.parseCommands(basedir, args().toArray(new String[0]),
o -> getLog().warn("Help option not supported"),
true);
reportDeprecatedProcessing();
if (additionalLicenseFiles != null) {
for (String licenseFile : additionalLicenseFiles) {
URI uri = new File(licenseFile).toURI();
Format fmt = Format.from(licenseFile);
MatcherReader mReader = fmt.matcherReader();
if (mReader != null) {
mReader.addMatchers(uri);
}
LicenseReader lReader = fmt.licenseReader();
if (lReader != null) {
lReader.addLicenses(uri);
config.addLicenses(lReader.readLicenses());
config.addApprovedLicenseCategories(lReader.approvedLicenseId());
}
}
}
if (families != null || getDeprecatedConfigs().findAny().isPresent()) {
if (log.isEnabled(Log.Level.DEBUG)) {
log.debug(format("%s license families loaded from pom", families.length));
}
Consumer<ILicenseFamily> logger = super.getLog().isDebugEnabled() ? l -> log.debug(format("Family: %s", l))
: l -> {
};
Consumer<ILicenseFamily> process = logger.andThen(config::addFamily);
getDeprecatedConfigs().map(DeprecatedConfig::getLicenseFamily).filter(Objects::nonNull).forEach(process);
if (families != null) { // TODO remove if check in v1.0
Arrays.stream(families).map(Family::build).forEach(process);
}
}
processLicenseFamilies(config);
if (approvedLicenses != null && approvedLicenses.length > 0) {
Arrays.stream(approvedLicenses).forEach(config::addApprovedLicenseCategory);
}
if (licenses != null) {
if (log.isEnabled(Log.Level.DEBUG)) {
log.debug(format("%s licenses loaded from pom", licenses.length));
}
Consumer<ILicense> logger = log.isEnabled(Log.Level.DEBUG) ? l -> log.debug(format("License: %s", l))
: l -> {
};
Consumer<ILicense> addApproved = (approvedLicenses == null || approvedLicenses.length == 0)
? l -> config.addApprovedLicenseCategory(l.getLicenseFamily())
: l -> {
};
Consumer<ILicense> process = logger.andThen(config::addLicense).andThen(addApproved);
SortedSet<ILicenseFamily> families = config.getLicenseFamilies(LicenseFilter.ALL);
getDeprecatedConfigs().map(DeprecatedConfig::getLicense).filter(Objects::nonNull)
.map(x -> x.setLicenseFamilies(families).build()).forEach(process);
getLicenses().map(x -> x.build(families)).forEach(process);
}
DocumentName dirName = DocumentName.builder(basedir).build();
config.addSource(new DirectoryWalker(new FileDocument(dirName, basedir, config.getDocumentExcluder(dirName))));
if (helpLicenses) {
new org.apache.rat.help.Licenses(config, new PrintWriter(log.asWriter())).printHelp();
}
reportConfiguration = config;
} catch (IOException e) {
throw new MojoExecutionException(e);
}
}
return reportConfiguration;
}