[NO ISSUE][LIC] Support multiple license content roots
Change-Id: Ic5f70c2382de0abe61e2d5767b8ce84e4b84e90a
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2682
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java
index 475ed50..17eba93 100644
--- a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java
+++ b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java
@@ -147,7 +147,12 @@
getLog().debug("Resolving content for " + artifact.getUrl() + " (" + artifact.getContentFile() + ")");
File cFile = new File(artifact.getContentFile());
if (!cFile.isAbsolute()) {
- cFile = new File(licenseDirectory, artifact.getContentFile());
+ for (File directory : licenseDirectories) {
+ cFile = new File(directory, artifact.getContentFile());
+ if (cFile.exists()) {
+ break;
+ }
+ }
}
if (!cFile.exists()) {
if (!bestEffort) {
diff --git a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseMojo.java b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseMojo.java
index a94727d..05ac62b 100644
--- a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseMojo.java
+++ b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseMojo.java
@@ -74,6 +74,9 @@
protected List<LicenseSpec> licenses = new ArrayList<>();
@Parameter
+ protected List<NoticeSpec> notices = new ArrayList<>();
+
+ @Parameter
protected Set<String> excludedScopes = new HashSet<>();
@Parameter
@@ -106,7 +109,10 @@
@Parameter(required = true)
private String location;
- @Parameter(required = true)
+ @Parameter
+ protected List<File> licenseDirectories = new ArrayList<>();
+
+ @Parameter
protected File licenseDirectory;
@Parameter
@@ -122,6 +128,7 @@
private List<Pattern> excludePatterns;
Map<String, LicenseSpec> urlToLicenseMap = new HashMap<>();
+ Map<String, NoticeSpec> urlToNoticeMap = new HashMap<>();
Map<String, LicensedProjects> licenseMap = new TreeMap<>();
private Map<Pair<String, ProjectFlag>, Object> projectFlags = new HashMap<>();
Map<String, String> noticeOverrides = new HashMap<String, String>();
@@ -133,6 +140,9 @@
}
protected void init() throws MojoExecutionException {
+ if (licenseDirectory != null) {
+ licenseDirectories.add(0, licenseDirectory);
+ }
if (warningTouchFile != null) {
warningTouchFile.getParentFile().mkdirs();
}
@@ -140,7 +150,7 @@
excludedScopes.add("system");
excludePatterns = compileExcludePatterns();
supplementModels = SupplementalModelHelper.loadSupplements(getLog(), models);
- buildUrlLicenseMap();
+ buildUrlMaps();
}
private void interceptLogs() {
@@ -321,7 +331,7 @@
}
}
- private void buildUrlLicenseMap() throws MojoExecutionException {
+ private void buildUrlMaps() throws MojoExecutionException {
for (LicenseSpec license : licenses) {
if (urlToLicenseMap.put(license.getUrl(), license) != null) {
throw new MojoExecutionException("Duplicate URL mapping: " + license.getUrl());
@@ -332,6 +342,16 @@
}
}
}
+ for (NoticeSpec notice : notices) {
+ if (urlToNoticeMap.put(notice.getUrl(), notice) != null) {
+ throw new MojoExecutionException("Duplicate URL mapping: " + notice.getUrl());
+ }
+ for (String alias : notice.getAliasUrls()) {
+ if (urlToNoticeMap.put(alias, notice) != null) {
+ throw new MojoExecutionException("Duplicate URL mapping: " + alias);
+ }
+ }
+ }
}
protected Map<MavenProject, List<Pair<String, String>>> gatherDependencies() throws ProjectBuildingException {