This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit dcc772d49360296e31ab2aea0f012908461a7db7 Author: Michael Blow <[email protected]> AuthorDate: Thu Jan 2 18:18:37 2025 -0500 [NO ISSUE][HYR][LIC] Enable license automation plugin to skip license/notice file content Ext-ref: MB-64542 Change-Id: Id51ed3c059795c377151fcbc45af1fea026435c9 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19244 Reviewed-by: Michael Blow <[email protected]> Reviewed-by: Hussain Towaileb <[email protected]> Tested-by: Michael Blow <[email protected]> --- .../hyracks/maven/license/GenerateFileMojo.java | 14 ++++++++++++-- .../apache/hyracks/maven/license/LicenseMojo.java | 21 +++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) 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 5c1110689f..0b9542901e 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 @@ -284,6 +284,9 @@ public class GenerateFileMojo extends LicenseMojo { } private void rebuildLicenseContentProjectMap() throws IOException { + if (skipLicenses) { + return; + } int counter = 0; Map<String, LicensedProjects> licenseMap2 = new TreeMap<>(WHITESPACE_NORMALIZED_COMPARATOR); for (LicensedProjects lps : licenseMap.values()) { @@ -333,6 +336,9 @@ public class GenerateFileMojo extends LicenseMojo { private void buildNoticeProjectMap() throws IOException { noticeMap = new TreeMap<>(WHITESPACE_NORMALIZED_COMPARATOR); + if (skipNotices) { + return; + } for (Project p : getProjects()) { String noticeText = p.getNoticeText(); if (noticeText == null && noticeOverrides.containsKey(p.gav())) { @@ -374,11 +380,15 @@ public class GenerateFileMojo extends LicenseMojo { } private void resolveNoticeFiles() throws MojoExecutionException, IOException { - resolveArtifactFiles(NOTICE); + if (!skipNotices) { + resolveArtifactFiles(NOTICE); + } } private void resolveLicenseFiles() throws MojoExecutionException, IOException { - resolveArtifactFiles(LICENSE); + if (!skipLicenses) { + resolveArtifactFiles(LICENSE); + } } private void resolveArtifactFiles(final EmbeddedArtifact artifact) throws MojoExecutionException, IOException { 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 3b5fde693d..5e9180714d 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 @@ -131,6 +131,12 @@ public abstract class LicenseMojo extends AbstractMojo { @Parameter protected List<String> extraDependencies = new ArrayList<>(); + @Parameter + protected boolean skipLicenses; + + @Parameter + protected boolean skipNotices; + private Map<String, MavenProject> projectCache = new HashMap<>(); private Map<String, Model> supplementModels; @@ -274,8 +280,18 @@ public abstract class LicenseMojo extends AbstractMojo { private void addDependencyToLicenseMap(MavenProject depProject, List<Pair<String, String>> depLicenses, String depLocation) { + LicenseSpec spec = extractLicenseSpec(depProject, depLicenses, depLocation); + addProject(new Project(depProject, depLocation, depProject.getArtifact().getFile(), + Boolean.parseBoolean(String.valueOf(depProject.getContextValue(SHADOWED_KEY)))), spec, true); + } + + private LicenseSpec extractLicenseSpec(MavenProject depProject, List<Pair<String, String>> depLicenses, + String depLocation) { final String depGav = toGav(depProject); getLog().debug("adding " + depGav + ", location: " + depLocation); + if (skipLicenses) { + return new LicenseSpec("DUMMY LICENSE", "DUMMY LICENSE"); + } final MutableBoolean usedMetric = new MutableBoolean(false); if (depLicenses.size() > 1) { Collections.sort(depLicenses, (o1, o2) -> { @@ -311,10 +327,7 @@ public abstract class LicenseMojo extends AbstractMojo { licenseUrl = fakeLicenseUrl; } } - addProject( - new Project(depProject, depLocation, depProject.getArtifact().getFile(), - Boolean.parseBoolean(String.valueOf(depProject.getContextValue(SHADOWED_KEY)))), - new LicenseSpec(licenseUrl, displayName), true); + return new LicenseSpec(licenseUrl, displayName); } protected void addProject(Project project, LicenseSpec spec, boolean additive) {
