Skip to content

Commit b69af90

Browse files
committed
[MJAVADOC-682] Reactor builds fail when multiple modules with same groupId:artifactId, but different versions
Co-authored-by: AO Industries, Inc <[email protected]> This closes #253
1 parent b47b280 commit b69af90

File tree

12 files changed

+303
-27
lines changed

12 files changed

+303
-27
lines changed

src/it/projects/MJAVADOC-567_aggr-mixed/verify.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def buildLog = new File(basedir,'build.log')
2222
def expectedLines = ['Creating an aggregated report for both named and unnamed modules is not possible.',
2323
'Ensure that every module has a module descriptor or is a jar with a MANIFEST.MF containing an Automatic-Module-Name.',
2424
'Fix the following projects:',
25-
' - testcase:module2']
25+
' - testcase:module2:1.0-SNAPSHOT']
2626

2727
def errorLines = buildLog.readLines()
2828
.dropWhile{ !it.startsWith('[ERROR] Creating') }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals = package
19+
invoker.java.version = 9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<parent>
27+
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
28+
<artifactId>mjavadoc682</artifactId>
29+
<version>1.0-SNAPSHOT</version>
30+
</parent>
31+
<artifactId>multiple-projects-same-module-name</artifactId>
32+
<version>1.0-SNAPSHOT</version>
33+
<packaging>jar</packaging>
34+
35+
<name>Module Version 1.x</name>
36+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.foo;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
/**
23+
* Bar 1.x.
24+
*/
25+
public class Bar
26+
{
27+
28+
public void run()
29+
{
30+
System.out.println( "Bar 1.x" );
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
module com.foo {
21+
exports com.foo;
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<parent>
27+
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
28+
<artifactId>mjavadoc682</artifactId>
29+
<version>1.0-SNAPSHOT</version>
30+
</parent>
31+
<artifactId>multiple-projects-same-module-name</artifactId>
32+
<version>2.0-SNAPSHOT</version>
33+
<packaging>jar</packaging>
34+
35+
<name>Module Version 2.x</name>
36+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.foo;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
/**
23+
* Bar 2.x.
24+
*/
25+
public class Bar
26+
{
27+
28+
public void run()
29+
{
30+
System.out.println( "Bar 2.x" );
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
module com.foo {
21+
exports com.foo;
22+
}

src/it/projects/MJAVADOC-682/pom.xml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
27+
<artifactId>mjavadoc682</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
<packaging>pom</packaging>
30+
31+
<url>https://issues.apache.org/jira/browse/MJAVADOC-682</url>
32+
33+
<properties>
34+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
35+
</properties>
36+
37+
<build>
38+
<pluginManagement>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-compiler-plugin</artifactId>
43+
<version>@compilerPluginVersion@</version>
44+
<configuration>
45+
<release>9</release>
46+
</configuration>
47+
</plugin>
48+
<plugin>
49+
<groupId>org.apache.maven.plugins</groupId>
50+
<artifactId>maven-javadoc-plugin</artifactId>
51+
<version>@project.version@</version>
52+
<configuration>
53+
<release>9</release>
54+
</configuration>
55+
</plugin>
56+
</plugins>
57+
</pluginManagement>
58+
<plugins>
59+
<plugin>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
<artifactId>maven-javadoc-plugin</artifactId>
62+
<executions>
63+
<execution>
64+
<id>attach-javadocs</id>
65+
<goals>
66+
<goal>jar</goal>
67+
</goals>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
</plugins>
72+
</build>
73+
74+
<modules>
75+
<module>module-1</module>
76+
<module>module-2</module>
77+
</modules>
78+
</project>

src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -2192,7 +2192,7 @@ protected Collection<JavadocModule> getSourcePaths() throws MavenReportException
21922192

21932193
if (!sourcePaths.isEmpty()) {
21942194
mappedSourcePaths.add(new JavadocModule(
2195-
ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()),
2195+
ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion()),
21962196
getClassesFile(project),
21972197
sourcePaths));
21982198
}
@@ -2206,12 +2206,12 @@ private JavadocModule buildJavadocModule(MavenProject project, Collection<Path>
22062206
ResolvePathResult resolvePathResult = getResolvePathResult(classessFile);
22072207
if (resolvePathResult == null) {
22082208
return new JavadocModule(
2209-
ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()),
2209+
ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion()),
22102210
classessFile,
22112211
sourcePaths);
22122212
} else {
22132213
return new JavadocModule(
2214-
ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()),
2214+
ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion()),
22152215
classessFile,
22162216
sourcePaths,
22172217
resolvePathResult.getModuleDescriptor(),
@@ -4398,7 +4398,8 @@ private void addJavadocOptions(
43984398
Map<String, MavenProject> reactorKeys = new HashMap<>(aggregatedProjects.size());
43994399
for (MavenProject reactorProject : aggregatedProjects) {
44004400
reactorKeys.put(
4401-
ArtifactUtils.versionlessKey(reactorProject.getGroupId(), reactorProject.getArtifactId()),
4401+
ArtifactUtils.key(
4402+
reactorProject.getGroupId(), reactorProject.getArtifactId(), reactorProject.getVersion()),
44024403
reactorProject);
44034404
}
44044405

@@ -4424,7 +4425,7 @@ private void addJavadocOptions(
44244425
if (moduleDescriptor != null) {
44254426
try {
44264427
allModuleDescriptors.put(
4427-
entry.getGa(),
4428+
entry.getGav(),
44284429
locationManager
44294430
.parseModuleDescriptor(moduleDescriptor)
44304431
.getModuleDescriptor());
@@ -4433,7 +4434,7 @@ private void addJavadocOptions(
44334434
}
44344435
}
44354436
} else {
4436-
allModuleDescriptors.put(entry.getGa(), entry.getModuleDescriptor());
4437+
allModuleDescriptors.put(entry.getGav(), entry.getModuleDescriptor());
44374438
}
44384439
}
44394440
}
@@ -4448,7 +4449,7 @@ private void addJavadocOptions(
44484449
if (supportModulePath && !allModuleDescriptors.isEmpty()) {
44494450
Collection<String> unnamedProjects = new ArrayList<>();
44504451
for (JavadocModule javadocModule : allSourcePaths) {
4451-
MavenProject aggregatedProject = reactorKeys.get(javadocModule.getGa());
4452+
MavenProject aggregatedProject = reactorKeys.get(javadocModule.getGav());
44524453
if (aggregatedProject != null && !"pom".equals(aggregatedProject.getPackaging())) {
44534454
ResolvePathResult result = null;
44544455

@@ -4497,15 +4498,15 @@ private void addJavadocOptions(
44974498
throw new MavenReportException(e.getMessage(), e);
44984499
}
44994500
} else {
4500-
unnamedProjects.add(javadocModule.getGa());
4501+
unnamedProjects.add(javadocModule.getGav());
45014502
}
45024503

45034504
if (aggregatedProject.equals(getProject())) {
45044505
mainResolvePathResult = result;
45054506
}
45064507
} else {
45074508
// todo
4508-
getLog().error("no reactor project: " + javadocModule.getGa());
4509+
getLog().error("no reactor project: " + javadocModule.getGav());
45094510
}
45104511
}
45114512

0 commit comments

Comments
 (0)