From 6a60371ad7911753218b9dae58876bc3829290a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Landh=C3=A4u=C3=9Fer?= Date: Mon, 20 Apr 2020 21:36:40 +0200 Subject: [PATCH] Integration test for ISSUE #351 --- src/it/ISSUE-351/invoker.properties | 23 ++++++ src/it/ISSUE-351/pom.xml | 78 +++++++++++++++++++ src/it/ISSUE-351/postbuild.groovy | 30 +++++++ .../license/override-THIRD-PARTY.properties | 1 + .../license/api/DefaultThirdPartyTool.java | 7 +- .../mojo/license/model/LicenseMap.java | 9 ++- 6 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 src/it/ISSUE-351/invoker.properties create mode 100644 src/it/ISSUE-351/pom.xml create mode 100644 src/it/ISSUE-351/postbuild.groovy create mode 100644 src/it/ISSUE-351/src/license/override-THIRD-PARTY.properties diff --git a/src/it/ISSUE-351/invoker.properties b/src/it/ISSUE-351/invoker.properties new file mode 100644 index 000000000..09bf32591 --- /dev/null +++ b/src/it/ISSUE-351/invoker.properties @@ -0,0 +1,23 @@ +### +# #%L +# License Maven Plugin +# %% +# Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Lesser Public License for more details. +# +# You should have received a copy of the GNU General Lesser Public +# License along with this program. If not, see +# . +# #L% +### +invoker.goals=clean license:add-third-party +invoker.failureBehavior=fail-fast \ No newline at end of file diff --git a/src/it/ISSUE-351/pom.xml b/src/it/ISSUE-351/pom.xml new file mode 100644 index 000000000..16afc845f --- /dev/null +++ b/src/it/ISSUE-351/pom.xml @@ -0,0 +1,78 @@ + + + + + + 4.0.0 + + org.codehaus.mojo.license.test + test-ISSUE-351 + @pom.version@ + + License Test :: ISSUE-351 + jar + + + + The GNU Lesser General Public License, Version 3.0 + http://www.gnu.org/licenses/lgpl-3.0.txt + repo + + + + + UTF-8 + true + true + true + true + true + + + + + org.glassfish.jersey.containers + jersey-container-servlet + 2.30.1 + + + + + + + + + + org.codehaus.mojo + license-maven-plugin + @pom.version@ + + + + + + + + diff --git a/src/it/ISSUE-351/postbuild.groovy b/src/it/ISSUE-351/postbuild.groovy new file mode 100644 index 000000000..af837dc6b --- /dev/null +++ b/src/it/ISSUE-351/postbuild.groovy @@ -0,0 +1,30 @@ +/* + * #%L + * License Maven Plugin + * %% + * Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * . + * #L% + */ + +file = new File(basedir, 'target/generated-sources/license/THIRD-PARTY.txt'); +assert file.exists(); +content = file.text; +assert content.contains('(Eclipse Public License 2.0) jersey-container-servlet (org.glassfish.jersey.containers:jersey-container-servlet:2.30.1 - https://projects.eclipse.org/projects/ee4j.jersey/project/jersey-container-servlet'); +assert !content.contains('(Apache License, 2.0) (BSD 2-Clause) (EDL 1.0) (EPL 2.0) (GPL2 w/ CPE) (MIT license) (Modified BSD) (Public Domain) (W3C license) (jQuery license) jersey-container-servlet (org.glassfish.jersey.containers:jersey-container-servlet:2.30.1 - https://projects.eclipse.org/projects/ee4j.jersey/project/jersey-container-servlet'); + + +return true; \ No newline at end of file diff --git a/src/it/ISSUE-351/src/license/override-THIRD-PARTY.properties b/src/it/ISSUE-351/src/license/override-THIRD-PARTY.properties new file mode 100644 index 000000000..ee76411b9 --- /dev/null +++ b/src/it/ISSUE-351/src/license/override-THIRD-PARTY.properties @@ -0,0 +1 @@ +org.glassfish.jersey.containers--jersey-container-servlet--2.30.1=Eclipse Public License 2.0 \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyTool.java b/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyTool.java index 7c48f9260..2245e6c6c 100644 --- a/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyTool.java +++ b/src/main/java/org/codehaus/mojo/license/api/DefaultThirdPartyTool.java @@ -625,13 +625,16 @@ public void overrideLicenses( LicenseMap licenseMap, SortedMap project[] map. List removedFrom = licenseMap.removeProject( project ); - LOG.info( "Overriding license(s) for dependency [{}] with [{}] (overriden licenses: [{}])", id, license, StringUtils.join(removedFrom.toArray(), ",")); + LOG.info( "Overriding license(s) for dependency [{}] with [{}], overriden license(s): [{}]", + id, + "(" + StringUtils.join( licenses, ") (" ) + ")", + "(" + StringUtils.join( removedFrom.toArray(), ") (" ) + ")" ); // add licenses to map addLicense( licenseMap, project, licenses ); diff --git a/src/main/java/org/codehaus/mojo/license/model/LicenseMap.java b/src/main/java/org/codehaus/mojo/license/model/LicenseMap.java index fee1af843..2e790bc68 100644 --- a/src/main/java/org/codehaus/mojo/license/model/LicenseMap.java +++ b/src/main/java/org/codehaus/mojo/license/model/LicenseMap.java @@ -173,11 +173,16 @@ public List removeProject( MavenProject project ) { if ( project.equals( mavenProject ) ) { - get( entry.getKey() ).remove( project ); - removedFrom.add(entry.getKey()); + removedFrom.add( entry.getKey() ); } } } + + for ( String r : removedFrom ) + { + get( r ).remove( project ); + } + return removedFrom; } }