You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/11/26 21:47:28 UTC

(maven-javadoc-plugin) branch MJAVADOC-682 created (now 6aca7bc5)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch MJAVADOC-682
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git


      at 6aca7bc5 [MJAVADOC-682] Reactor builds fail when multiple modules with same groupId:artifactId, but different versions

This branch includes the following new commits:

     new 6aca7bc5 [MJAVADOC-682] Reactor builds fail when multiple modules with same groupId:artifactId, but different versions

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven-javadoc-plugin) 01/01: [MJAVADOC-682] Reactor builds fail when multiple modules with same groupId:artifactId, but different versions

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MJAVADOC-682
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git

commit 6aca7bc597db1ca644b8996cb92d87de2a5b8b14
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Nov 26 22:47:19 2023 +0100

    [MJAVADOC-682] Reactor builds fail when multiple modules with same groupId:artifactId, but different versions
---
 .../maven/plugins/javadoc/AbstractJavadocMojo.java    | 19 ++++++++++---------
 .../apache/maven/plugins/javadoc/JavadocModule.java   | 14 +++++++-------
 .../plugins/javadoc/resolver/ResourceResolver.java    | 16 ++++++----------
 3 files changed, 23 insertions(+), 26 deletions(-)

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 9fdbad2c..884068eb 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 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
 
             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 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
         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 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
         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);
         }
 
@@ -4424,7 +4425,7 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
                     if (moduleDescriptor != null) {
                         try {
                             allModuleDescriptors.put(
-                                    entry.getGa(),
+                                    entry.getGav(),
                                     locationManager
                                             .parseModuleDescriptor(moduleDescriptor)
                                             .getModuleDescriptor());
@@ -4433,7 +4434,7 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
                         }
                     }
                 } else {
-                    allModuleDescriptors.put(entry.getGa(), entry.getModuleDescriptor());
+                    allModuleDescriptors.put(entry.getGav(), entry.getModuleDescriptor());
                 }
             }
         }
@@ -4448,7 +4449,7 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
         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;
 
@@ -4497,7 +4498,7 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
                             throw new MavenReportException(e.getMessage(), e);
                         }
                     } else {
-                        unnamedProjects.add(javadocModule.getGa());
+                        unnamedProjects.add(javadocModule.getGav());
                     }
 
                     if (aggregatedProject.equals(getProject())) {
@@ -4505,7 +4506,7 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
                     }
                 } 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 8c477941..144a0f43 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 @@ import org.codehaus.plexus.languages.java.jpms.ModuleNameSource;
  * @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<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() {
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 ffbd0b46..53cf3b28 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 java.util.Set;
 
 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 final class ResourceResolver extends AbstractLogEnabled {
         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);
             }
         }
 
@@ -110,8 +111,7 @@ public final class ResourceResolver extends AbstractLogEnabled {
 
         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 {
@@ -137,14 +137,14 @@ public final class ResourceResolver extends AbstractLogEnabled {
         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)));
@@ -269,7 +269,7 @@ public final class ResourceResolver extends AbstractLogEnabled {
 
         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(
@@ -377,8 +377,4 @@ public final class ResourceResolver extends AbstractLogEnabled {
 
         return JavadocUtil.pruneDirs(reactorProject, dirs);
     }
-
-    private static String key(final String gid, final String aid) {
-        return gid + ":" + aid;
-    }
 }