diff --git a/src/it/projects/MJAVADOC-567_aggr-mixed/verify.groovy b/src/it/projects/MJAVADOC-567_aggr-mixed/verify.groovy index d1e34c5c9..3fcfe7f56 100644 --- a/src/it/projects/MJAVADOC-567_aggr-mixed/verify.groovy +++ b/src/it/projects/MJAVADOC-567_aggr-mixed/verify.groovy @@ -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') } diff --git a/src/it/projects/MJAVADOC-682/invoker.properties b/src/it/projects/MJAVADOC-682/invoker.properties new file mode 100644 index 000000000..fca4651cf --- /dev/null +++ b/src/it/projects/MJAVADOC-682/invoker.properties @@ -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+ diff --git a/src/it/projects/MJAVADOC-682/module-1/pom.xml b/src/it/projects/MJAVADOC-682/module-1/pom.xml new file mode 100644 index 000000000..cb301188e --- /dev/null +++ b/src/it/projects/MJAVADOC-682/module-1/pom.xml @@ -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> diff --git a/src/it/projects/MJAVADOC-682/module-1/src/main/java/com/foo/Bar.java b/src/it/projects/MJAVADOC-682/module-1/src/main/java/com/foo/Bar.java new file mode 100644 index 000000000..34fd9ffa9 --- /dev/null +++ b/src/it/projects/MJAVADOC-682/module-1/src/main/java/com/foo/Bar.java @@ -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" ); + } + +} diff --git a/src/it/projects/MJAVADOC-682/module-1/src/main/java/module-info.java b/src/it/projects/MJAVADOC-682/module-1/src/main/java/module-info.java new file mode 100644 index 000000000..87ac6c86a --- /dev/null +++ b/src/it/projects/MJAVADOC-682/module-1/src/main/java/module-info.java @@ -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; +} diff --git a/src/it/projects/MJAVADOC-682/module-2/pom.xml b/src/it/projects/MJAVADOC-682/module-2/pom.xml new file mode 100644 index 000000000..afb2c5945 --- /dev/null +++ b/src/it/projects/MJAVADOC-682/module-2/pom.xml @@ -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> diff --git a/src/it/projects/MJAVADOC-682/module-2/src/main/java/com/foo/Bar.java b/src/it/projects/MJAVADOC-682/module-2/src/main/java/com/foo/Bar.java new file mode 100644 index 000000000..3b39bee86 --- /dev/null +++ b/src/it/projects/MJAVADOC-682/module-2/src/main/java/com/foo/Bar.java @@ -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" ); + } + +} diff --git a/src/it/projects/MJAVADOC-682/module-2/src/main/java/module-info.java b/src/it/projects/MJAVADOC-682/module-2/src/main/java/module-info.java new file mode 100644 index 000000000..87ac6c86a --- /dev/null +++ b/src/it/projects/MJAVADOC-682/module-2/src/main/java/module-info.java @@ -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; +} diff --git a/src/it/projects/MJAVADOC-682/pom.xml b/src/it/projects/MJAVADOC-682/pom.xml new file mode 100644 index 000000000..2bc5eb52f --- /dev/null +++ b/src/it/projects/MJAVADOC-682/pom.xml @@ -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> 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 a07a0bcb4..10127379e 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<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)); } @@ -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(), @@ -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); } @@ -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<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 @@ 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<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 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<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); } } @@ -110,8 +111,7 @@ public List<JavadocBundle> resolveDependencyJavadocBundles(final SourceResolverC 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 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))); @@ -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( @@ -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; - } }