Skip to content

Commit e29c4bf

Browse files
tpage-alfrescoslachiewicz
authored andcommitted
Fix #345 Only log override warning if licenseMerges provided.
1 parent b69fce2 commit e29c4bf

File tree

9 files changed

+177
-3
lines changed

9 files changed

+177
-3
lines changed

src/it/ISSUE-345-2/invoker.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
invoker.goals=clean license:add-third-party
2+
invoker.failureBehavior=fail-fast

src/it/ISSUE-345-2/license.merges

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APACHE|The Apache Software License, Version 2.0

src/it/ISSUE-345-2/pom.xml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
#%L
4+
License Maven Plugin
5+
%%
6+
Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit
7+
%%
8+
This program is free software: you can redistribute it and/or modify
9+
it under the terms of the GNU Lesser General Public License as
10+
published by the Free Software Foundation, either version 3 of the
11+
License, or (at your option) any later version.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
GNU General Lesser Public License for more details.
17+
18+
You should have received a copy of the GNU General Lesser Public
19+
License along with this program. If not, see
20+
<http://www.gnu.org/licenses/lgpl-3.0.html>.
21+
#L%
22+
-->
23+
24+
<project xmlns="http://maven.apache.org/POM/4.0.0"
25+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
26+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
27+
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<groupId>org.codehaus.mojo.license.test</groupId>
31+
<artifactId>issue-345-2</artifactId>
32+
<version>@pom.version@</version>
33+
34+
<name>License Test :: ISSUE-345-2</name>
35+
36+
<properties>
37+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38+
<license.verbose>true</license.verbose>
39+
<license.licenseMergesUrl>${project.baseUri}license.merges</license.licenseMergesUrl>
40+
</properties>
41+
42+
<build>
43+
<pluginManagement>
44+
<plugins>
45+
<plugin>
46+
<groupId>org.codehaus.mojo</groupId>
47+
<artifactId>license-maven-plugin</artifactId>
48+
<version>@pom.version@</version>
49+
<configuration>
50+
<licenseMerges>
51+
<licenseMerge>Apache-2.0|The Apache Software License, Version 2.0</licenseMerge>
52+
</licenseMerges>
53+
</configuration>
54+
</plugin>
55+
</plugins>
56+
</pluginManagement>
57+
</build>
58+
59+
<dependencies>
60+
<dependency>
61+
<groupId>commons-logging</groupId>
62+
<artifactId>commons-logging</artifactId>
63+
<version>1.1.1</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.apache.commons</groupId>
67+
<artifactId>commons-lang3</artifactId>
68+
<version>3.8.1</version>
69+
</dependency>
70+
</dependencies>
71+
72+
</project>

src/it/ISSUE-345-2/postbuild.groovy

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Check that the licenseMergesUrl is used.
2+
file = new File(basedir, 'target/generated-sources/license/THIRD-PARTY.txt')
3+
assert file.exists()
4+
content = file.text
5+
assert !content.contains('the project has no dependencies.')
6+
assert content.contains('(APACHE) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)')
7+
8+
// Check that there's a warning about licenseMerges being overridden.
9+
file = new File(basedir, 'build.log')
10+
assert file.exists()
11+
content = file.text
12+
assert content.contains('licenseMerges will be overridden by licenseMergesUrl.')
13+
return true

src/it/ISSUE-345/invoker.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
invoker.goals=clean license:add-third-party
2+
invoker.failureBehavior=fail-fast

src/it/ISSUE-345/license.merges

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APACHE|The Apache Software License, Version 2.0

src/it/ISSUE-345/pom.xml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
#%L
4+
License Maven Plugin
5+
%%
6+
Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit
7+
%%
8+
This program is free software: you can redistribute it and/or modify
9+
it under the terms of the GNU Lesser General Public License as
10+
published by the Free Software Foundation, either version 3 of the
11+
License, or (at your option) any later version.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
GNU General Lesser Public License for more details.
17+
18+
You should have received a copy of the GNU General Lesser Public
19+
License along with this program. If not, see
20+
<http://www.gnu.org/licenses/lgpl-3.0.html>.
21+
#L%
22+
-->
23+
24+
<project xmlns="http://maven.apache.org/POM/4.0.0"
25+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
26+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
27+
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<groupId>org.codehaus.mojo.license.test</groupId>
31+
<artifactId>issue-345</artifactId>
32+
<version>@pom.version@</version>
33+
34+
<name>License Test :: ISSUE-345</name>
35+
36+
<properties>
37+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38+
<license.verbose>true</license.verbose>
39+
<license.licenseMergesUrl>${project.baseUri}license.merges</license.licenseMergesUrl>
40+
</properties>
41+
42+
<build>
43+
<pluginManagement>
44+
<plugins>
45+
<plugin>
46+
<groupId>org.codehaus.mojo</groupId>
47+
<artifactId>license-maven-plugin</artifactId>
48+
<version>@pom.version@</version>
49+
</plugin>
50+
</plugins>
51+
</pluginManagement>
52+
</build>
53+
54+
<dependencies>
55+
<dependency>
56+
<groupId>commons-logging</groupId>
57+
<artifactId>commons-logging</artifactId>
58+
<version>1.1.1</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.apache.commons</groupId>
62+
<artifactId>commons-lang3</artifactId>
63+
<version>3.8.1</version>
64+
</dependency>
65+
</dependencies>
66+
67+
</project>

src/it/ISSUE-345/postbuild.groovy

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Check that the licenseMergesUrl is used.
2+
file = new File(basedir, 'target/generated-sources/license/THIRD-PARTY.txt')
3+
assert file.exists()
4+
content = file.text
5+
assert !content.contains('the project has no dependencies.')
6+
assert content.contains('(APACHE) Commons Logging (commons-logging:commons-logging:1.1.1 - http://commons.apache.org/logging)')
7+
8+
// Since no licenseMerges was provided then there should be no warning.
9+
file = new File(basedir, 'build.log')
10+
assert file.exists()
11+
content = file.text
12+
assert !content.contains('licenseMerges will be overridden by licenseMergesUrl.')
13+
return true

src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,12 @@ protected void init()
766766
}
767767
else if ( licenseMergesUrl != null )
768768
{
769-
LOG.warn( "" );
770-
LOG.warn( "licenseMerges will be overridden by licenseMergesUrl." );
771-
LOG.warn( "" );
769+
if ( licenseMerges != null )
770+
{
771+
LOG.warn( "" );
772+
LOG.warn( "licenseMerges will be overridden by licenseMergesUrl." );
773+
LOG.warn( "" );
774+
}
772775
if ( UrlRequester.isStringUrl( licenseMergesUrl ) )
773776
{
774777
licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ).split( "[\n\r]+" ) );

0 commit comments

Comments
 (0)