Skip to content

Commit 4eff254

Browse files
authored
Merge pull request #325 from srdo/issue-324
Fix #324 Remove unnecessary manual dependency resolution
2 parents 19796fa + 7c5006c commit 4eff254

8 files changed

Lines changed: 127 additions & 215 deletions

File tree

src/it/ISSUE-324/README.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Demonstrates that the aggregateAddThirdParty plugin only resolves the actually used version of a dependency, and not all versions that are present in transitive dependencies.
2+
3+
The project contains a child2 that depends on hbase-annotations:2.1.3. It also contains child1 which depends on hive-hcatalog-core:2.3.4. The Hive dependency also depends on hbase-annotations, but in a much older version, and through a longer dependency chain. The old hbase-annotations artifact depends on jdk.tools, which is not present in Java 9+.
4+
5+
The plugin execution will fail if the plugin attempts to resolve jdk.tools on Java 9+. This test is therefore only meaningful on Java 9+, and will pass spuriously on earlier versions.

src/it/ISSUE-324/child1/pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.codehaus.mojo.license.test</groupId>
6+
<artifactId>test-ISSUE-324</artifactId>
7+
<version>@pom.version@</version>
8+
</parent>
9+
<artifactId>test-ISSUE-324-child1</artifactId>
10+
<packaging>jar</packaging>
11+
12+
<dependencies>
13+
<!-- Depends on old hbase-annotations, which depends on jdk.tools -->
14+
<dependency>
15+
<groupId>org.apache.hive.hcatalog</groupId>
16+
<artifactId>hive-hcatalog-core</artifactId>
17+
<version>2.3.4</version>
18+
</dependency>
19+
<!-- This has a newer hbase-annotations without jdk.tools. This path to hbase-annotations is shorter, so has precedence -->
20+
<dependency>
21+
<groupId>org.codehaus.mojo.license.test</groupId>
22+
<artifactId>test-ISSUE-324-child2</artifactId>
23+
<version>@pom.version@</version>
24+
</dependency>
25+
</dependencies>
26+
</project>

src/it/ISSUE-324/child2/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.codehaus.mojo.license.test</groupId>
6+
<artifactId>test-ISSUE-324</artifactId>
7+
<version>@pom.version@</version>
8+
</parent>
9+
<artifactId>test-ISSUE-324-child2</artifactId>
10+
<packaging>jar</packaging>
11+
12+
<dependencies>
13+
<dependency>
14+
<groupId>org.apache.hbase</groupId>
15+
<artifactId>hbase-annotations</artifactId>
16+
<version>2.1.3</version>
17+
</dependency>
18+
</dependencies>
19+
</project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
###
2+
# #%L
3+
# License Maven Plugin
4+
# %%
5+
# Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit
6+
# %%
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Lesser General Public License as
9+
# published by the Free Software Foundation, either version 3 of the
10+
# License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Lesser Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Lesser Public
18+
# License along with this program. If not, see
19+
# <http://www.gnu.org/licenses/lgpl-3.0.html>.
20+
# #L%
21+
###
22+
invoker.goals=clean package -e
23+
invoker.failureBehavior=fail-fast

src/it/ISSUE-324/pom.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.codehaus.mojo.license.test</groupId>
6+
<artifactId>test-ISSUE-324</artifactId>
7+
<version>@pom.version@</version>
8+
<name>License Test :: ISSUE-324</name>
9+
<packaging>pom</packaging>
10+
11+
<licenses>
12+
<license>
13+
<name>The GNU Lesser General Public License, Version 3.0</name>
14+
<url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
15+
<distribution>repo</distribution>
16+
</license>
17+
</licenses>
18+
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<license.verbose>true</license.verbose>
22+
</properties>
23+
24+
<modules>
25+
<module>child1</module>
26+
<module>child2</module>
27+
</modules>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.codehaus.mojo</groupId>
33+
<artifactId>license-maven-plugin</artifactId>
34+
<inherited>false</inherited>
35+
<version>@pom.version@</version>
36+
<configuration>
37+
<excludedScopes>system,test</excludedScopes>
38+
</configuration>
39+
<executions>
40+
<execution>
41+
<id>generate-and-check-licenses</id>
42+
<goals>
43+
<goal>aggregate-add-third-party</goal>
44+
</goals>
45+
</execution>
46+
</executions>
47+
</plugin>
48+
</plugins>
49+
</build>
50+
</project>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,8 @@ Collection<ThirdPartyDetails> createThirdPartyDetails( MavenProject project, boo
565565
ResolvedProjectDependencies loadedDependencies;
566566
if ( loadArtifacts )
567567
{
568-
loadedDependencies = dependenciesTool.loadProjectArtifacts( localRepository,
569-
project.getRemoteArtifactRepositories(), project, null );
568+
loadedDependencies =
569+
new ResolvedProjectDependencies( project.getArtifacts(), project.getDependencyArtifacts() );
570570
}
571571
else
572572
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ protected ResolvedProjectDependencies resolveDependencyArtifacts() throws Depend
238238
}
239239
if ( isAggregatorBuild )
240240
{
241-
dependencyArtifacts = dependenciesTool.loadProjectArtifacts( localRepository, remoteRepositories,
242-
project, reactorProjectDependencies );
241+
dependencyArtifacts =
242+
new ResolvedProjectDependencies( project.getArtifacts(), project.getDependencyArtifacts() );
243243
}
244244
else
245245
{

0 commit comments

Comments
 (0)