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
  • Loading branch information
michael-o committed Nov 26, 2023
1 parent 488624f commit 6aca7bc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @since 3.3.0
*/
public class JavadocModule {
private final String ga;
private final String gav;

private final File artifactFile;

Expand All @@ -41,25 +41,25 @@ public class JavadocModule {

private final ModuleNameSource moduleNameSource;

public JavadocModule(String ga, File artifactFile, Collection<Path> sourcePaths) {
this(ga, artifactFile, sourcePaths, null, null);
public JavadocModule(String gav, File artifactFile, Collection<Path> sourcePaths) {
this(gav, artifactFile, sourcePaths, null, null);
}

public JavadocModule(
String ga,
String gav,
File artifactFile,
Collection<Path> sourcePaths,
JavaModuleDescriptor moduleDescriptor,
ModuleNameSource moduleNameSource) {
this.ga = ga;
this.gav = gav;
this.artifactFile = artifactFile;
this.sourcePaths = sourcePaths;
this.moduleDescriptor = moduleDescriptor;
this.moduleNameSource = moduleNameSource;
}

public String getGa() {
return ga;
public String getGav() {
return gav;
}

public Collection<Path> getSourcePaths() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.plugins.javadoc.AbstractJavadocMojo;
Expand Down Expand Up @@ -102,16 +103,15 @@ public List<JavadocBundle> resolveDependencyJavadocBundles(final SourceResolverC
final Map<String, MavenProject> projectMap = new HashMap<>();
if (config.reactorProjects() != null) {
for (final MavenProject p : config.reactorProjects()) {
projectMap.put(key(p.getGroupId(), p.getArtifactId()), p);
projectMap.put(ArtifactUtils.key(p.getGroupId(), p.getArtifactId(), p.getVersion()), p);
}
}

final List<Artifact> artifacts = config.project().getTestArtifacts();

final List<Artifact> forResourceResolution = new ArrayList<>(artifacts.size());
for (final Artifact artifact : artifacts) {
final String key = key(artifact.getGroupId(), artifact.getArtifactId());
final MavenProject p = projectMap.get(key);
final MavenProject p = projectMap.get(ArtifactUtils.key(artifact));
if (p != null) {
bundles.addAll(resolveBundleFromProject(config, p, artifact));
} else {
Expand All @@ -137,14 +137,14 @@ public Collection<JavadocModule> resolveDependencySourcePaths(final SourceResolv
final Map<String, MavenProject> projectMap = new HashMap<>();
if (config.reactorProjects() != null) {
for (final MavenProject p : config.reactorProjects()) {
projectMap.put(key(p.getGroupId(), p.getArtifactId()), p);
projectMap.put(ArtifactUtils.key(p.getGroupId(), p.getArtifactId(), p.getVersion()), p);
}
}

final List<Artifact> artifacts = config.project().getTestArtifacts();

for (final Artifact artifact : artifacts) {
final String key = key(artifact.getGroupId(), artifact.getArtifactId());
final String key = ArtifactUtils.key(artifact);
final MavenProject p = projectMap.get(key);
if (p != null) {
mappedDirs.add(new JavadocModule(key, artifact.getFile(), resolveFromProject(config, p, artifact)));
Expand Down Expand Up @@ -269,7 +269,7 @@ private JavadocModule resolveFromArtifact(final SourceResolverConfig config, fin

Collection<Path> sourcePaths = resolveAndUnpack(toResolve, config, SOURCE_VALID_CLASSIFIERS, true);

return new JavadocModule(key(artifact.getGroupId(), artifact.getArtifactId()), artifact.getFile(), sourcePaths);
return new JavadocModule(ArtifactUtils.key(artifact), artifact.getFile(), sourcePaths);
}

private org.eclipse.aether.artifact.Artifact createResourceArtifact(
Expand Down Expand Up @@ -377,8 +377,4 @@ private static Collection<Path> resolveFromProject(

return JavadocUtil.pruneDirs(reactorProject, dirs);
}

private static String key(final String gid, final String aid) {
return gid + ":" + aid;
}
}

0 comments on commit 6aca7bc

Please sign in to comment.