Skip to content

Commit

Permalink
Fix #345 Only log override warning if licenseMerges provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpage-alfresco authored and slachiewicz committed Mar 25, 2022
1 parent b69fce2 commit e29c4bf
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/it/ISSUE-345-2/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=clean license:add-third-party
invoker.failureBehavior=fail-fast
1 change: 1 addition & 0 deletions src/it/ISSUE-345-2/license.merges
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APACHE|The Apache Software License, Version 2.0
72 changes: 72 additions & 0 deletions src/it/ISSUE-345-2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%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%
-->

<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>issue-345-2</artifactId>
<version>@pom.version@</version>

<name>License Test :: ISSUE-345-2</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<license.verbose>true</license.verbose>
<license.licenseMergesUrl>${project.baseUri}license.merges</license.licenseMergesUrl>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
<licenseMerges>
<licenseMerge>Apache-2.0|The Apache Software License, Version 2.0</licenseMerge>
</licenseMerges>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>

</project>
13 changes: 13 additions & 0 deletions src/it/ISSUE-345-2/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Check that the licenseMergesUrl is used.
file = new File(basedir, 'target/generated-sources/license/THIRD-PARTY.txt')
assert file.exists()
content = file.text
assert !content.contains('the project has no dependencies.')
assert content.contains('(APACHE) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)')

// Check that there's a warning about licenseMerges being overridden.
file = new File(basedir, 'build.log')
assert file.exists()
content = file.text
assert content.contains('licenseMerges will be overridden by licenseMergesUrl.')
return true
2 changes: 2 additions & 0 deletions src/it/ISSUE-345/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=clean license:add-third-party
invoker.failureBehavior=fail-fast
1 change: 1 addition & 0 deletions src/it/ISSUE-345/license.merges
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APACHE|The Apache Software License, Version 2.0
67 changes: 67 additions & 0 deletions src/it/ISSUE-345/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%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%
-->

<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>issue-345</artifactId>
<version>@pom.version@</version>

<name>License Test :: ISSUE-345</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<license.verbose>true</license.verbose>
<license.licenseMergesUrl>${project.baseUri}license.merges</license.licenseMergesUrl>
</properties>

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

<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>

</project>
13 changes: 13 additions & 0 deletions src/it/ISSUE-345/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Check that the licenseMergesUrl is used.
file = new File(basedir, 'target/generated-sources/license/THIRD-PARTY.txt')
assert file.exists()
content = file.text
assert !content.contains('the project has no dependencies.')
assert content.contains('(APACHE) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)')

// Since no licenseMerges was provided then there should be no warning.
file = new File(basedir, 'build.log')
assert file.exists()
content = file.text
assert !content.contains('licenseMerges will be overridden by licenseMergesUrl.')
return true
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,12 @@ protected void init()
}
else if ( licenseMergesUrl != null )
{
LOG.warn( "" );
LOG.warn( "licenseMerges will be overridden by licenseMergesUrl." );
LOG.warn( "" );
if ( licenseMerges != null )
{
LOG.warn( "" );
LOG.warn( "licenseMerges will be overridden by licenseMergesUrl." );
LOG.warn( "" );
}
if ( UrlRequester.isStringUrl( licenseMergesUrl ) )
{
licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ).split( "[\n\r]+" ) );
Expand Down

0 comments on commit e29c4bf

Please sign in to comment.