Minor Improvements To License Generation Plugin
- also move stax:stax overrides to supplemental-models.xml
Change-Id: I6ede22dd7e79571133033975901bdacc22d5befe
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1419
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/ExtraLicenseFile.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/ExtraLicenseFile.java
index 3b3e190..6a0c163 100644
--- a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/ExtraLicenseFile.java
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/ExtraLicenseFile.java
@@ -23,6 +23,7 @@
public class ExtraLicenseFile {
private File file;
private String location;
+ private boolean additive = true;
public String getLocation() {
return location;
@@ -39,4 +40,12 @@
public void setFile(File file) {
this.file = file;
}
+
+ public boolean isAdditive() {
+ return additive;
+ }
+
+ public void setAdditive(boolean additive) {
+ this.additive = additive;
+ }
}
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java
index 894b73d..179d426 100644
--- a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java
@@ -96,6 +96,9 @@
@Parameter
protected Map<String, String> templateProperties = new HashMap<>();
+ @Parameter
+ private boolean stripFoundationAssertionFromNotices = true;
+
private SortedMap<String, SortedSet<Project>> noticeMap;
@java.lang.Override
@@ -207,7 +210,7 @@
}
for (Project project : projects.getProjects()) {
project.setLocation(extraLicenseFile.getLocation());
- addProject(project, projects.getLicense());
+ addProject(project, projects.getLicense(), extraLicenseFile.isAdditive());
}
}
}
@@ -271,7 +274,8 @@
private void resolveNoticeFiles() throws MojoExecutionException, IOException {
resolveArtifactFiles("NOTICE", entry -> entry.getName().matches("(.*/|^)" + "NOTICE" + "(.txt)?"),
- Project::setNoticeText, text -> FOUNDATION_PATTERN.matcher(text).replaceAll(""));
+ Project::setNoticeText,
+ text -> stripFoundationAssertionFromNotices ? FOUNDATION_PATTERN.matcher(text).replaceAll("") : text);
}
private void resolveLicenseFiles() throws MojoExecutionException, IOException {
@@ -287,22 +291,24 @@
if (!artifactFile.exists()) {
throw new MojoExecutionException("Artifact file " + artifactFile + " does not exist!");
} else if (!artifactFile.getName().endsWith(".jar")) {
- throw new MojoExecutionException("Unknown artifact file type: " + artifactFile);
+ getLog().info("Skipping unknown artifact file type: " + artifactFile);
+ continue;
}
try (JarFile jarFile = new JarFile(artifactFile)) {
SortedMap<String, JarEntry> matches = gatherMatchingEntries(jarFile,
filter);
if (matches.isEmpty()) {
getLog().warn("No " + name + " file found for " + project.gav());
- continue;
- } else if (matches.size() > 1) {
- getLog().warn("Multiple " + name + " files found for " + project.gav() + ": " + matches.keySet()
- + "; taking first");
} else {
- getLog().info(project.gav() + " has " + name + " file: " + matches.keySet());
+ if (matches.size() > 1) {
+ getLog().warn("Multiple " + name + " files found for " + project.gav() + ": " + matches.keySet()
+ + "; taking first");
+ } else {
+ getLog().info(project.gav() + " has " + name + " file: " + matches.keySet());
+ }
+ resolveContent(project, jarFile, matches.values().iterator().next(),
+ contentTransformer, consumer, name);
}
- resolveContent(project, jarFile, matches.values().iterator().next(),
- contentTransformer, consumer, name);
}
}
}
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java
index 846c9b6..debb06f 100644
--- a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java
@@ -160,15 +160,20 @@
}
}
File path = new File(localRepository.getBasedir(), localRepository.pathOf(depProject.getArtifact()));
- addProject(new Project(depProject, depLocation, path), new LicenseSpec(licenseUrl, displayName));
+ addProject(new Project(depProject, depLocation, path), new LicenseSpec(licenseUrl, displayName), true);
}
- protected void addProject(Project project, LicenseSpec licenseSpecNew) {
- String licenseUrl = licenseSpecNew.getUrl();
+ protected void addProject(Project project, LicenseSpec spec, boolean additive) {
+ String licenseUrl = spec.getUrl();
LicenseSpec license = urlToLicenseMap.get(licenseUrl);
if (license == null) {
- license = licenseSpecNew;
+ license = spec;
urlToLicenseMap.put(licenseUrl, license);
+ for (String alias : license.getAliasUrls()) {
+ if (!urlToLicenseMap.containsKey(alias)) {
+ urlToLicenseMap.put(alias ,license);
+ }
+ }
}
licenseUrl = license.getUrl();
LicensedProjects entry = licenseMap.get(licenseUrl);
@@ -176,7 +181,9 @@
entry = new LicensedProjects(license);
licenseMap.put(licenseUrl, entry);
}
- entry.addProject(project);
+ if (additive || entry.getProjects().contains(project)) {
+ entry.addProject(project);
+ }
}
private void buildUrlLicenseMap() throws MojoExecutionException {
@@ -188,7 +195,6 @@
if (urlToLicenseMap.put(alias ,license) != null) {
throw new MojoExecutionException("Duplicate URL mapping: " + alias);
}
-
}
}
}
diff --git a/asterixdb/asterix-server/pom.xml b/asterixdb/asterix-server/pom.xml
index 1f8c79c..1049088 100644
--- a/asterixdb/asterix-server/pom.xml
+++ b/asterixdb/asterix-server/pom.xml
@@ -82,14 +82,6 @@
</models>
<overrides>
<override>
- <gav>stax:stax:1.1.1-dev</gav>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </override>
- <override>
- <gav>stax:stax:1.2.0</gav>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </override>
- <override>
<gav>org.tukaani:xz:1.0</gav>
<url>PUBLIC_DOMAIN</url>
</override>
diff --git a/asterixdb/src/main/appended-resources/supplemental-models.xml b/asterixdb/src/main/appended-resources/supplemental-models.xml
index 10d7290..93a0740 100644
--- a/asterixdb/src/main/appended-resources/supplemental-models.xml
+++ b/asterixdb/src/main/appended-resources/supplemental-models.xml
@@ -162,6 +162,21 @@
</supplement>
<supplement>
<project>
+ <groupId>stax</groupId>
+ <artifactId>stax</artifactId>
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
+ <properties>
+ <verifiedVersions>1.1.1-dev,1.2.0</verifiedVersions>
+ </properties>
+ </project>
+ </supplement>
+ <supplement>
+ <project>
<groupId>wss4j</groupId>
<artifactId>wss4j</artifactId>
<name>Apache WSS4J</name>