You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2021/08/30 17:24:30 UTC
[maven-javadoc-plugin] 03/03: [MJAVADOC-618] Goal javadoc:aggregate
fails with submodules packaged as war
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit 0d0e0cc7325fc27b89b7bde0ba2cbe322ff6a040
Author: rfscholte <rf...@apache.org>
AuthorDate: Mon Aug 30 19:24:13 2021 +0200
[MJAVADOC-618] Goal javadoc:aggregate fails with submodules packaged as war
---
.../projects/MJAVADOC-618_modular-war/app/pom.xml | 63 +++++++++++++++
.../main/java/com/mycompany/app/Application.java} | 41 +---------
.../app/src/main/java/module-info.java} | 43 +----------
.../app/src/main/webapp/WEB-INF/web.xml | 26 +++++++
.../MJAVADOC-618_modular-war/invoker.properties | 18 +++++
.../projects/MJAVADOC-618_modular-war/lib/pom.xml | 45 +++++++++++
.../src/main/java/com/mycompany/lib/Library.java} | 40 +---------
.../lib/src/main/java/module-info.java} | 43 +----------
src/it/projects/MJAVADOC-618_modular-war/pom.xml | 68 +++++++++++++++++
.../MJAVADOC-618_modular-war/verify.groovy | 23 ++++++
.../maven/plugins/javadoc/AbstractJavadocMojo.java | 89 +++++++++++++++-------
.../maven/plugins/javadoc/JavadocModule.java | 31 +++++++-
12 files changed, 344 insertions(+), 186 deletions(-)
diff --git a/src/it/projects/MJAVADOC-618_modular-war/app/pom.xml b/src/it/projects/MJAVADOC-618_modular-war/app/pom.xml
new file mode 100644
index 0000000..58e2798
--- /dev/null
+++ b/src/it/projects/MJAVADOC-618_modular-war/app/pom.xml
@@ -0,0 +1,63 @@
+<?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>
+ <artifactId>example-root</artifactId>
+ <groupId>com.mycompany</groupId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>com.mycompany</groupId>
+ <artifactId>myproject</artifactId>
+ <packaging>war</packaging>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>3.3.1</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.mycompany</groupId>
+ <artifactId>lib</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/com/mycompany/app/Application.java
similarity index 50%
copy from src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
copy to src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/com/mycompany/app/Application.java
index 31c6cc6..e7ef773 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
+++ b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/com/mycompany/app/Application.java
@@ -1,4 +1,4 @@
-package org.apache.maven.plugins.javadoc;
+package com.mycompany.app;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,42 +19,9 @@ package org.apache.maven.plugins.javadoc;
* under the License.
*/
-import java.io.File;
-import java.nio.file.Path;
-import java.util.Collection;
+import com.mycompany.lib.Library;
-/**
- * Represents a unit of Javadoc referring to the binary and java source paths
- *
- * @since 3.3.0
- */
-public class JavadocModule
+public class Application
{
- private final String ga;
-
- private final File artifactFile;
-
- private final Collection<Path> sourcePaths;
-
- public JavadocModule( String ga, File artifactFile, Collection<Path> sourcePaths )
- {
- this.ga = ga;
- this.artifactFile = artifactFile;
- this.sourcePaths = sourcePaths;
- }
-
- public String getGa()
- {
- return ga;
- }
-
- public Collection<Path> getSourcePaths()
- {
- return sourcePaths;
- }
-
- public File getArtifactFile()
- {
- return artifactFile;
- }
+ private Library library = new Library();
}
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/module-info.java
similarity index 50%
copy from src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
copy to src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/module-info.java
index 31c6cc6..0267725 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
+++ b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/java/module-info.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.javadoc;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,42 +17,7 @@ package org.apache.maven.plugins.javadoc;
* under the License.
*/
-import java.io.File;
-import java.nio.file.Path;
-import java.util.Collection;
-
-/**
- * Represents a unit of Javadoc referring to the binary and java source paths
- *
- * @since 3.3.0
- */
-public class JavadocModule
+module com.mycompany.app
{
- private final String ga;
-
- private final File artifactFile;
-
- private final Collection<Path> sourcePaths;
-
- public JavadocModule( String ga, File artifactFile, Collection<Path> sourcePaths )
- {
- this.ga = ga;
- this.artifactFile = artifactFile;
- this.sourcePaths = sourcePaths;
- }
-
- public String getGa()
- {
- return ga;
- }
-
- public Collection<Path> getSourcePaths()
- {
- return sourcePaths;
- }
-
- public File getArtifactFile()
- {
- return artifactFile;
- }
-}
+ requires com.mycompany.lib;
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-618_modular-war/app/src/main/webapp/WEB-INF/web.xml b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..ba5f22e
--- /dev/null
+++ b/src/it/projects/MJAVADOC-618_modular-war/app/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,26 @@
+<?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.
+ -->
+
+<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_1.xsd"
+ version="3.1">
+
+ <display-name>myproject</display-name>
+</web-app>
diff --git a/src/it/projects/MJAVADOC-618_modular-war/invoker.properties b/src/it/projects/MJAVADOC-618_modular-war/invoker.properties
new file mode 100644
index 0000000..a087705
--- /dev/null
+++ b/src/it/projects/MJAVADOC-618_modular-war/invoker.properties
@@ -0,0 +1,18 @@
+# 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.java.version = 11+
+invoker.goals = package javadoc:aggregate-jar
diff --git a/src/it/projects/MJAVADOC-618_modular-war/lib/pom.xml b/src/it/projects/MJAVADOC-618_modular-war/lib/pom.xml
new file mode 100644
index 0000000..1700d8c
--- /dev/null
+++ b/src/it/projects/MJAVADOC-618_modular-war/lib/pom.xml
@@ -0,0 +1,45 @@
+<?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
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.mycompany</groupId>
+ <artifactId>example-root</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>lib</artifactId>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.2</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java b/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/com/mycompany/lib/Library.java
similarity index 50%
copy from src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
copy to src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/com/mycompany/lib/Library.java
index 31c6cc6..dcb8801 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
+++ b/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/com/mycompany/lib/Library.java
@@ -1,4 +1,4 @@
-package org.apache.maven.plugins.javadoc;
+package com.mycompany.lib;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,42 +19,6 @@ package org.apache.maven.plugins.javadoc;
* under the License.
*/
-import java.io.File;
-import java.nio.file.Path;
-import java.util.Collection;
-
-/**
- * Represents a unit of Javadoc referring to the binary and java source paths
- *
- * @since 3.3.0
- */
-public class JavadocModule
+public class Library
{
- private final String ga;
-
- private final File artifactFile;
-
- private final Collection<Path> sourcePaths;
-
- public JavadocModule( String ga, File artifactFile, Collection<Path> sourcePaths )
- {
- this.ga = ga;
- this.artifactFile = artifactFile;
- this.sourcePaths = sourcePaths;
- }
-
- public String getGa()
- {
- return ga;
- }
-
- public Collection<Path> getSourcePaths()
- {
- return sourcePaths;
- }
-
- public File getArtifactFile()
- {
- return artifactFile;
- }
}
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java b/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/module-info.java
similarity index 50%
copy from src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
copy to src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/module-info.java
index 31c6cc6..3c6c193 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
+++ b/src/it/projects/MJAVADOC-618_modular-war/lib/src/main/java/module-info.java
@@ -1,5 +1,3 @@
-package org.apache.maven.plugins.javadoc;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,42 +17,7 @@ package org.apache.maven.plugins.javadoc;
* under the License.
*/
-import java.io.File;
-import java.nio.file.Path;
-import java.util.Collection;
-
-/**
- * Represents a unit of Javadoc referring to the binary and java source paths
- *
- * @since 3.3.0
- */
-public class JavadocModule
+module com.mycompany.lib
{
- private final String ga;
-
- private final File artifactFile;
-
- private final Collection<Path> sourcePaths;
-
- public JavadocModule( String ga, File artifactFile, Collection<Path> sourcePaths )
- {
- this.ga = ga;
- this.artifactFile = artifactFile;
- this.sourcePaths = sourcePaths;
- }
-
- public String getGa()
- {
- return ga;
- }
-
- public Collection<Path> getSourcePaths()
- {
- return sourcePaths;
- }
-
- public File getArtifactFile()
- {
- return artifactFile;
- }
-}
+ exports com.mycompany.lib;
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-618_modular-war/pom.xml b/src/it/projects/MJAVADOC-618_modular-war/pom.xml
new file mode 100644
index 0000000..a8f2bac
--- /dev/null
+++ b/src/it/projects/MJAVADOC-618_modular-war/pom.xml
@@ -0,0 +1,68 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.mycompany</groupId>
+ <artifactId>example-root</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>example-root</name>
+
+ <modules>
+ <module>lib</module>
+ <module>app</module>
+ </modules>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ <configuration>
+ <source>11</source>
+ <target>11</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <quiet>true</quiet>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/src/it/projects/MJAVADOC-618_modular-war/verify.groovy b/src/it/projects/MJAVADOC-618_modular-war/verify.groovy
new file mode 100644
index 0000000..d665081
--- /dev/null
+++ b/src/it/projects/MJAVADOC-618_modular-war/verify.groovy
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, 'target/apidocs/argfile').readLines().size() == 2
+assert new File( basedir, 'target/apidocs/com.mycompany.lib/com/mycompany/lib/Library.html').exists()
+// module descriptor of com.mycompany.app has no exports, so nothing is documented
+assert !new File( basedir, 'target/apidocs/com.mycompany.app/com/mycompany/app/Application.html').exists()
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 41d3b2c..db5198c 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -1891,21 +1891,46 @@ public abstract class AbstractJavadocMojo
return Collections.singletonList( new File( p.getBuild().getOutputDirectory() ) );
}
- protected File getArtifactFile( MavenProject project )
+ /**
+ * Either returns the attached artifact file or outputDirectory
+ *
+ * @param project
+ * @return
+ */
+ protected File getClassesFile( MavenProject project )
{
if ( !isAggregator() && isTest() )
{
return null;
}
- else if ( project.getArtifact() != null && project.getArtifact().getFile() != null )
+
+ if ( project.getArtifact() != null && project.getArtifact().getFile() != null )
+ {
+ File artifactFile = project.getArtifact().getFile();
+ if ( artifactFile.isDirectory() || artifactFile.getName().endsWith( ".jar" ) )
+ {
+ return artifactFile;
+ }
+ }
+ else if ( project.getExecutionProject() != null
+ && project.getExecutionProject().getArtifact() != null
+ && project.getExecutionProject().getArtifact().getFile() != null )
{
- return project.getArtifact().getFile();
+ File artifactFile = project.getExecutionProject().getArtifact().getFile();
+ if ( artifactFile.isDirectory() || artifactFile.getName().endsWith( ".jar" ) )
+ {
+ return artifactFile;
+ }
}
- else if ( project.getExecutionProject() != null && project.getExecutionProject().getArtifact() != null )
+
+ if ( project.getBuild().getOutputDirectory() != null )
{
- return project.getExecutionProject().getArtifact().getFile();
+ return new File( project.getBuild().getOutputDirectory() );
+ }
+ else
+ {
+ return null;
}
- return null;
}
/**
@@ -2399,10 +2424,7 @@ public abstract class AbstractJavadocMojo
}
if ( !sourcePaths.isEmpty() )
{
- mappedSourcePaths.add( new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(),
- project.getArtifactId() ),
- getArtifactFile( project ),
- sourcePaths ) );
+ mappedSourcePaths.add( buildJavadocModule( project, sourcePaths ) );
}
}
@@ -2443,11 +2465,7 @@ public abstract class AbstractJavadocMojo
if ( !additionalSourcePaths.isEmpty() )
{
- mappedSourcePaths.add( new JavadocModule(
- ArtifactUtils.versionlessKey( subProject.getGroupId(),
- subProject.getArtifactId() ),
- getArtifactFile( subProject ),
- additionalSourcePaths ) );
+ mappedSourcePaths.add( buildJavadocModule( subProject , additionalSourcePaths ) );
}
}
}
@@ -2474,13 +2492,33 @@ public abstract class AbstractJavadocMojo
{
mappedSourcePaths.add( new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(),
project.getArtifactId() ),
- getArtifactFile( project ),
+ getClassesFile( project ),
sourcePaths ) );
}
}
return mappedSourcePaths;
}
+
+ private JavadocModule buildJavadocModule( MavenProject project, Collection<Path> sourcePaths )
+ {
+ File classessFile = getClassesFile( project );
+ ResolvePathResult resolvePathResult = getResolvePathResult( classessFile );
+ if ( resolvePathResult == null )
+ {
+ return new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ),
+ classessFile,
+ sourcePaths );
+ }
+ else
+ {
+ return new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ),
+ classessFile,
+ sourcePaths,
+ resolvePathResult.getModuleDescriptor(),
+ resolvePathResult.getModuleNameSource() );
+ }
+ }
/**
* Recursively add the modules of the aggregatedProject to the set of aggregatedModules.
@@ -2811,7 +2849,7 @@ public abstract class AbstractJavadocMojo
{
if ( subProject != project )
{
- File projectArtifactFile = getArtifactFile( subProject );
+ File projectArtifactFile = getClassesFile( subProject );
if ( projectArtifactFile != null )
{
classpathElements.add( projectArtifactFile );
@@ -4683,11 +4721,11 @@ public abstract class AbstractJavadocMojo
continue;
}
- int lastIndexOfSeparator = currentFile.lastIndexOf( File.separatorChar );
+ int lastIndexOfSeparator = currentFile.lastIndexOf( '/' );
if ( lastIndexOfSeparator != -1 )
{
String packagename =
- currentFile.substring( 0, lastIndexOfSeparator ).replace( File.separatorChar, '.' );
+ currentFile.substring( 0, lastIndexOfSeparator ).replace( '/', '.' );
if ( exportAllPackages || exportedPackages.contains( packagename ) )
{
@@ -5128,7 +5166,6 @@ public abstract class AbstractJavadocMojo
Map<String, JavaModuleDescriptor> allModuleDescriptors = new HashMap<>();
-
boolean supportModulePath = javadocRuntimeVersion.isAtLeast( "9" );
if ( release != null )
{
@@ -5143,11 +5180,7 @@ public abstract class AbstractJavadocMojo
{
for ( JavadocModule entry : allSourcePaths )
{
- File artifactFile = entry.getArtifactFile();
-
- ResolvePathResult resolvePathResult = getResolvePathResult( artifactFile );
-
- if ( resolvePathResult == null || resolvePathResult.getModuleNameSource() == ModuleNameSource.FILENAME )
+ if ( entry.getModuleNameSource() == null || entry.getModuleNameSource() == ModuleNameSource.FILENAME )
{
Path moduleDescriptor = findMainDescriptor( entry.getSourcePaths() );
@@ -5166,7 +5199,7 @@ public abstract class AbstractJavadocMojo
}
else
{
- allModuleDescriptors.put( entry.getGa(), resolvePathResult.getModuleDescriptor() );
+ allModuleDescriptors.put( entry.getGa(), entry.getModuleDescriptor() );
}
}
}
@@ -5189,7 +5222,7 @@ public abstract class AbstractJavadocMojo
ResolvePathResult result = null;
// Prefer jar over outputDirectory, since it may may contain an automatic module name
- File artifactFile = getArtifactFile( aggregatedProject );
+ File artifactFile = getClassesFile( aggregatedProject );
if ( artifactFile != null )
{
ResolvePathRequest<File> request = ResolvePathRequest.ofFile( artifactFile );
@@ -5314,7 +5347,7 @@ public abstract class AbstractJavadocMojo
|| ModuleNameSource.MANIFEST.equals( mainModuleNameSource ) ) )
{
List<File> pathElements = new ArrayList<>( getPathElements() );
- File artifactFile = getArtifactFile( project );
+ File artifactFile = getClassesFile( project );
if ( artifactFile != null )
{
pathElements.add( 0, artifactFile );
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 31c6cc6..85cfc43 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
@@ -23,6 +23,9 @@ import java.io.File;
import java.nio.file.Path;
import java.util.Collection;
+import org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor;
+import org.codehaus.plexus.languages.java.jpms.ModuleNameSource;
+
/**
* Represents a unit of Javadoc referring to the binary and java source paths
*
@@ -31,16 +34,28 @@ import java.util.Collection;
public class JavadocModule
{
private final String ga;
-
+
private final File artifactFile;
-
+
private final Collection<Path> sourcePaths;
+ private final JavaModuleDescriptor moduleDescriptor;
+
+ private final ModuleNameSource moduleNameSource;
+
public JavadocModule( String ga, File artifactFile, Collection<Path> sourcePaths )
{
+ this( ga, artifactFile, sourcePaths, null, null );
+ }
+
+ public JavadocModule( String ga, File artifactFile, Collection<Path> sourcePaths,
+ JavaModuleDescriptor moduleDescriptor, ModuleNameSource moduleNameSource )
+ {
this.ga = ga;
this.artifactFile = artifactFile;
this.sourcePaths = sourcePaths;
+ this.moduleDescriptor = moduleDescriptor;
+ this.moduleNameSource = moduleNameSource;
}
public String getGa()
@@ -52,9 +67,19 @@ public class JavadocModule
{
return sourcePaths;
}
-
+
public File getArtifactFile()
{
return artifactFile;
}
+
+ public JavaModuleDescriptor getModuleDescriptor()
+ {
+ return moduleDescriptor;
+ }
+
+ public ModuleNameSource getModuleNameSource()
+ {
+ return moduleNameSource;
+ }
}