>From Michael Blow <[email protected]>: Michael Blow has submitted this change. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19244 )
Change subject: [NO ISSUE][HYR][LIC] Enable license automation plugin to skip license/notice file content ...................................................................... [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]> --- M hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseMojo.java M hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java 2 files changed, 43 insertions(+), 6 deletions(-) Approvals: Michael Blow: Looks good to me, but someone else must approve; Verified Hussain Towaileb: Looks good to me, approved 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 5c11106..0b95429 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 @@ } 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 @@ 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 @@ } 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 3b5fde6..5e91807 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 @@ @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 @@ 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 @@ 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) { -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19244 To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: neo Gerrit-Change-Id: Id51ed3c059795c377151fcbc45af1fea026435c9 Gerrit-Change-Number: 19244 Gerrit-PatchSet: 2 Gerrit-Owner: Michael Blow <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Hussain Towaileb <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Michael Blow <[email protected]> Gerrit-MessageType: merged
