Skip to content

Commit

Permalink
Integration test for ISSUE mojohaus#351
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Landhäußer committed Apr 20, 2020
1 parent 4cc19df commit 6a60371
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 4 deletions.
23 changes: 23 additions & 0 deletions src/it/ISSUE-351/invoker.properties
Original file line number Diff line number Diff line change
@@ -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
# <http://www.gnu.org/licenses/lgpl-3.0.html>.
# #L%
###
invoker.goals=clean license:add-third-party
invoker.failureBehavior=fail-fast
78 changes: 78 additions & 0 deletions src/it/ISSUE-351/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
License Maven Plugin
%%
Copyright (C) 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
<http://www.gnu.org/licenses/lgpl-3.0.html>.
#L%
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.codehaus.mojo.license.test</groupId>
<artifactId>test-ISSUE-351</artifactId>
<version>@pom.version@</version>

<name>License Test :: ISSUE-351</name>
<packaging>jar</packaging>

<licenses>
<license>
<name>The GNU Lesser General Public License, Version 3.0</name>
<url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<license.verbose>true</license.verbose>
<license.useMissingFile>true</license.useMissingFile>
<license.deployMissingFile>true</license.deployMissingFile>
<license.useRepositoryMissingFiles>true</license.useRepositoryMissingFiles>
<license.failIfWarning>true</license.failIfWarning>
</properties>

<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.30.1</version>
</dependency>
</dependencies>

<build>

<pluginManagement>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>@pom.version@</version>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>


30 changes: 30 additions & 0 deletions src/it/ISSUE-351/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -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
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #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;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.glassfish.jersey.containers--jersey-container-servlet--2.30.1=Eclipse Public License 2.0
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,16 @@ public void overrideLicenses( LicenseMap licenseMap, SortedMap<String, MavenProj
if ( ArrayUtils.isEmpty( licenses ) )
{
// empty license means not fill, skip it
LOG.debug( " Not overriding license for dependency [{}] because no override given", id);
LOG.debug( " Not overriding license for dependency [{}] because no override given", id );
continue;
}

// remove project only removes first occurrence of project from license -> project[] map.
List<String> 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 );
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/org/codehaus/mojo/license/model/LicenseMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,16 @@ public List<String> 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;
}
}

0 comments on commit 6a60371

Please sign in to comment.