diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java index 9fdbad2c6..884068eb3 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -2192,7 +2192,7 @@ protected Collection 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)); } @@ -2206,12 +2206,12 @@ private JavadocModule buildJavadocModule(MavenProject project, Collection 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(), @@ -4398,7 +4398,8 @@ private void addJavadocOptions( Map 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); } @@ -4424,7 +4425,7 @@ private void addJavadocOptions( if (moduleDescriptor != null) { try { allModuleDescriptors.put( - entry.getGa(), + entry.getGav(), locationManager .parseModuleDescriptor(moduleDescriptor) .getModuleDescriptor()); @@ -4433,7 +4434,7 @@ private void addJavadocOptions( } } } else { - allModuleDescriptors.put(entry.getGa(), entry.getModuleDescriptor()); + allModuleDescriptors.put(entry.getGav(), entry.getModuleDescriptor()); } } } @@ -4448,7 +4449,7 @@ private void addJavadocOptions( if (supportModulePath && !allModuleDescriptors.isEmpty()) { Collection 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; @@ -4497,7 +4498,7 @@ private void addJavadocOptions( throw new MavenReportException(e.getMessage(), e); } } else { - unnamedProjects.add(javadocModule.getGa()); + unnamedProjects.add(javadocModule.getGav()); } if (aggregatedProject.equals(getProject())) { @@ -4505,7 +4506,7 @@ private void addJavadocOptions( } } else { // todo - getLog().error("no reactor project: " + javadocModule.getGa()); + getLog().error("no reactor project: " + javadocModule.getGav()); } } diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java index 8c477941b..144a0f43b 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java @@ -31,7 +31,7 @@ * @since 3.3.0 */ public class JavadocModule { - private final String ga; + private final String gav; private final File artifactFile; @@ -41,25 +41,25 @@ public class JavadocModule { private final ModuleNameSource moduleNameSource; - public JavadocModule(String ga, File artifactFile, Collection sourcePaths) { - this(ga, artifactFile, sourcePaths, null, null); + public JavadocModule(String gav, File artifactFile, Collection sourcePaths) { + this(gav, artifactFile, sourcePaths, null, null); } public JavadocModule( - String ga, + String gav, File artifactFile, Collection 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 getSourcePaths() { diff --git a/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java b/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java index ffbd0b464..53cf3b280 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java @@ -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; @@ -102,7 +103,7 @@ public List resolveDependencyJavadocBundles(final SourceResolverC final Map 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); } } @@ -110,8 +111,7 @@ public List resolveDependencyJavadocBundles(final SourceResolverC final List 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 { @@ -137,14 +137,14 @@ public Collection resolveDependencySourcePaths(final SourceResolv final Map 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 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))); @@ -269,7 +269,7 @@ private JavadocModule resolveFromArtifact(final SourceResolverConfig config, fin Collection 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( @@ -377,8 +377,4 @@ private static Collection resolveFromProject( return JavadocUtil.pruneDirs(reactorProject, dirs); } - - private static String key(final String gid, final String aid) { - return gid + ":" + aid; - } }