Skip to content

Commit

Permalink
[MJAVADOC-682] Reactor builds fail when multiple modules with same gr…
Browse files Browse the repository at this point in the history
…oupId:artifactId, but different versions

Co-authored-by: AO Industries, Inc <support@aoindustries.com>

This closes #253
  • Loading branch information
michael-o committed Nov 30, 2023
1 parent b47b280 commit b69af90
Show file tree
Hide file tree
Showing 12 changed files with 303 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/it/projects/MJAVADOC-567_aggr-mixed/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def buildLog = new File(basedir,'build.log')
def expectedLines = ['Creating an aggregated report for both named and unnamed modules is not possible.',
'Ensure that every module has a module descriptor or is a jar with a MANIFEST.MF containing an Automatic-Module-Name.',
'Fix the following projects:',
' - testcase:module2']
' - testcase:module2:1.0-SNAPSHOT']

def errorLines = buildLog.readLines()
.dropWhile{ !it.startsWith('[ERROR] Creating') }
Expand Down
19 changes: 19 additions & 0 deletions src/it/projects/MJAVADOC-682/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

invoker.goals = package
invoker.java.version = 9+
36 changes: 36 additions & 0 deletions src/it/projects/MJAVADOC-682/module-1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<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>

<parent>
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc682</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>multiple-projects-same-module-name</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Module Version 1.x</name>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.foo;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* Bar 1.x.
*/
public class Bar
{

public void run()
{
System.out.println( "Bar 1.x" );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

module com.foo {
exports com.foo;
}
36 changes: 36 additions & 0 deletions src/it/projects/MJAVADOC-682/module-2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<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>

<parent>
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc682</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>multiple-projects-same-module-name</artifactId>
<version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Module Version 2.x</name>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.foo;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* Bar 2.x.
*/
public class Bar
{

public void run()
{
System.out.println( "Bar 2.x" );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

module com.foo {
exports com.foo;
}
78 changes: 78 additions & 0 deletions src/it/projects/MJAVADOC-682/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<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.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc682</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<url>https://issues.apache.org/jira/browse/MJAVADOC-682</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>@compilerPluginVersion@</version>
<configuration>
<release>9</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<release>9</release>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<modules>
<module>module-1</module>
<module>module-2</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2192,7 +2192,7 @@ protected Collection<JavadocModule> getSourcePaths() throws MavenReportException

if (!sourcePaths.isEmpty()) {
mappedSourcePaths.add(new JavadocModule(
ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()),
ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion()),
getClassesFile(project),
sourcePaths));
}
Expand All @@ -2206,12 +2206,12 @@ private JavadocModule buildJavadocModule(MavenProject project, Collection<Path>
ResolvePathResult resolvePathResult = getResolvePathResult(classessFile);
if (resolvePathResult == null) {
return new JavadocModule(
ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()),
ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion()),
classessFile,
sourcePaths);
} else {
return new JavadocModule(
ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()),
ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion()),
classessFile,
sourcePaths,
resolvePathResult.getModuleDescriptor(),
Expand Down Expand Up @@ -4398,7 +4398,8 @@ private void addJavadocOptions(
Map<String, MavenProject> reactorKeys = new HashMap<>(aggregatedProjects.size());
for (MavenProject reactorProject : aggregatedProjects) {
reactorKeys.put(
ArtifactUtils.versionlessKey(reactorProject.getGroupId(), reactorProject.getArtifactId()),
ArtifactUtils.key(
reactorProject.getGroupId(), reactorProject.getArtifactId(), reactorProject.getVersion()),
reactorProject);
}

Expand All @@ -4424,7 +4425,7 @@ private void addJavadocOptions(
if (moduleDescriptor != null) {
try {
allModuleDescriptors.put(
entry.getGa(),
entry.getGav(),
locationManager
.parseModuleDescriptor(moduleDescriptor)
.getModuleDescriptor());
Expand All @@ -4433,7 +4434,7 @@ private void addJavadocOptions(
}
}
} else {
allModuleDescriptors.put(entry.getGa(), entry.getModuleDescriptor());
allModuleDescriptors.put(entry.getGav(), entry.getModuleDescriptor());
}
}
}
Expand All @@ -4448,7 +4449,7 @@ private void addJavadocOptions(
if (supportModulePath && !allModuleDescriptors.isEmpty()) {
Collection<String> unnamedProjects = new ArrayList<>();
for (JavadocModule javadocModule : allSourcePaths) {
MavenProject aggregatedProject = reactorKeys.get(javadocModule.getGa());
MavenProject aggregatedProject = reactorKeys.get(javadocModule.getGav());
if (aggregatedProject != null && !"pom".equals(aggregatedProject.getPackaging())) {
ResolvePathResult result = null;

Expand Down Expand Up @@ -4497,15 +4498,15 @@ private void addJavadocOptions(
throw new MavenReportException(e.getMessage(), e);
}
} else {
unnamedProjects.add(javadocModule.getGa());
unnamedProjects.add(javadocModule.getGav());
}

if (aggregatedProject.equals(getProject())) {
mainResolvePathResult = result;
}
} else {
// todo
getLog().error("no reactor project: " + javadocModule.getGa());
getLog().error("no reactor project: " + javadocModule.getGav());
}
}

Expand Down
Loading

0 comments on commit b69af90

Please sign in to comment.