[MJAVADOC-449] javadoc:aggregate fails with JDK 9
diff --git a/pom.xml b/pom.xml
index cccd3f0..43011e6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -237,7 +237,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-java</artifactId>
- <version>0.9.8</version>
+ <version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
diff --git a/src/it/projects/MJAVADOC-449_aggr_modulepath/invoker.properties b/src/it/projects/MJAVADOC-449_aggr_modulepath/invoker.properties
new file mode 100644
index 0000000..fb9625f
--- /dev/null
+++ b/src/it/projects/MJAVADOC-449_aggr_modulepath/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.java.version = 9+
+invoker.goals=javadoc:aggregate
+
diff --git a/src/it/projects/MJAVADOC-449_aggr_modulepath/modulea/pom.xml b/src/it/projects/MJAVADOC-449_aggr_modulepath/modulea/pom.xml
new file mode 100644
index 0000000..aa6921b
--- /dev/null
+++ b/src/it/projects/MJAVADOC-449_aggr_modulepath/modulea/pom.xml
@@ -0,0 +1,32 @@
+<!-- ~ 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>modulea</groupId>
+ <artifactId>modulea</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.0</version>
+ <configuration>
+ <release>9</release>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/projects/MJAVADOC-449_aggr_modulepath/modulea/src/main/java/com/javamodularity/modulea/HelloWorld.java b/src/it/projects/MJAVADOC-449_aggr_modulepath/modulea/src/main/java/com/javamodularity/modulea/HelloWorld.java
new file mode 100644
index 0000000..26447fc
--- /dev/null
+++ b/src/it/projects/MJAVADOC-449_aggr_modulepath/modulea/src/main/java/com/javamodularity/modulea/HelloWorld.java
@@ -0,0 +1,37 @@
+package com.javamodularity.modulea;
+
+/*
+ * 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.
+ */
+
+/**
+ * <p>Javadoc aggregation from module a.</p>
+ */
+public class HelloWorld {
+
+ /**
+ * <p>method f does something</p>
+ */
+ public void f() {
+ }
+
+ public static void main(String... args) {
+ System.out.println("Hello Modular World!");
+ }
+
+}
diff --git a/src/it/projects/MJAVADOC-449_aggr_modulepath/modulea/src/main/java/module-info.java b/src/it/projects/MJAVADOC-449_aggr_modulepath/modulea/src/main/java/module-info.java
new file mode 100644
index 0000000..f716447
--- /dev/null
+++ b/src/it/projects/MJAVADOC-449_aggr_modulepath/modulea/src/main/java/module-info.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * <p>modulea does something</p>
+ */
+module modulea {
+ exports com.javamodularity.modulea;
+}
diff --git a/src/it/projects/MJAVADOC-449_aggr_modulepath/moduleb/pom.xml b/src/it/projects/MJAVADOC-449_aggr_modulepath/moduleb/pom.xml
new file mode 100644
index 0000000..c4a7557
--- /dev/null
+++ b/src/it/projects/MJAVADOC-449_aggr_modulepath/moduleb/pom.xml
@@ -0,0 +1,32 @@
+<!-- ~ 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>moduleb</groupId>
+ <artifactId>moduleb</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.0</version>
+ <configuration>
+ <release>9</release>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/projects/MJAVADOC-449_aggr_modulepath/moduleb/src/main/java/com/javamodularity/moduleb/HelloWorld.java b/src/it/projects/MJAVADOC-449_aggr_modulepath/moduleb/src/main/java/com/javamodularity/moduleb/HelloWorld.java
new file mode 100644
index 0000000..4d9f4d2
--- /dev/null
+++ b/src/it/projects/MJAVADOC-449_aggr_modulepath/moduleb/src/main/java/com/javamodularity/moduleb/HelloWorld.java
@@ -0,0 +1,37 @@
+package com.javamodularity.moduleb;
+
+/*
+ * 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.
+ */
+
+/**
+ * <p>Javadoc aggregation from module a.</p>
+ */
+public class HelloWorld {
+
+ /**
+ * <p>method f does something</p>
+ */
+ public void f() {
+ }
+
+ public static void main(String... args) {
+ System.out.println("Hello Modular World!");
+ }
+
+}
diff --git a/src/it/projects/MJAVADOC-449_aggr_modulepath/moduleb/src/main/java/module-info.java b/src/it/projects/MJAVADOC-449_aggr_modulepath/moduleb/src/main/java/module-info.java
new file mode 100644
index 0000000..bcf2890
--- /dev/null
+++ b/src/it/projects/MJAVADOC-449_aggr_modulepath/moduleb/src/main/java/module-info.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * <p>moduleb does something</p>
+ */
+module moduleb {
+ exports com.javamodularity.moduleb;
+}
diff --git a/src/it/projects/MJAVADOC-449_aggr_modulepath/pom.xml b/src/it/projects/MJAVADOC-449_aggr_modulepath/pom.xml
new file mode 100644
index 0000000..d77f74d
--- /dev/null
+++ b/src/it/projects/MJAVADOC-449_aggr_modulepath/pom.xml
@@ -0,0 +1,35 @@
+<?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>parent</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <modules>
+ <module>modulea</module>
+ <module>moduleb</module>
+ </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/projects/MJAVADOC-449_aggr_modulepath/verify.groovy b/src/it/projects/MJAVADOC-449_aggr_modulepath/verify.groovy
new file mode 100644
index 0000000..28fdb1f
--- /dev/null
+++ b/src/it/projects/MJAVADOC-449_aggr_modulepath/verify.groovy
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+int javaVersion = System.getProperty( "java.specification.version" ) as Integer
+if ( javaVersion >= 11 ) {
+ def index = new File( basedir, 'target/site/apidocs/index.html')
+
+ assert index.text =~ /<a href="modulea\/module-summary\.html">modulea<\/a>/
+ assert index.text =~ /<a href="moduleb\/module-summary\.html">moduleb<\/a>/
+
+ assert new File( basedir, 'target/site/apidocs/modulea/module-summary.html').exists()
+ assert new File( basedir, 'target/site/apidocs/moduleb/module-summary.html').exists()
+}
+else {
+ def overview = new File( basedir, 'target/site/apidocs/overview-summary.html')
+
+ assert overview.text =~ /<a href="modulea-summary.html">modulea<\/a>/
+ assert overview.text =~ /<a href="moduleb-summary.html">moduleb<\/a>/
+
+ assert new File( basedir, 'target/site/apidocs/modulea-summary.html').exists()
+ assert new File( basedir, 'target/site/apidocs/moduleb-summary.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 2f571d6..b4da580 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -4684,46 +4684,7 @@
{
addArgIf( arguments, breakiterator, "-breakiterator", SINCE_JAVADOC_1_5 );
}
-
- List<String> roots = getProjectSourceRoots( getProject() );
- File mainDescriptor = findMainDescriptor( roots );
-
- final LocationManager locationManager = new LocationManager();
-
- if ( mainDescriptor != null && !isTest() )
- {
- ResolvePathsRequest<File> request =
- ResolvePathsRequest.withFiles( getPathElements() ).setMainModuleDescriptor( mainDescriptor );
- try
- {
- ResolvePathsResult<File> result = locationManager.resolvePaths( request );
-
- String classpath = StringUtils.join( result.getClasspathElements().iterator(), File.pathSeparator );
- addArgIfNotEmpty( arguments, "--class-path", JavadocUtil.quotedPathArgument( classpath ) );
-
- Set<File> modulePathElements = new HashSet<>( result.getModulepathElements().keySet() ) ;
- if ( allSourcePaths.size() > 1 )
- {
- // Probably required due to bug in javadoc (Java 9+)
- modulePathElements.addAll( getProjectBuildOutputDirs( getProject() ) );
- }
-
- String modulepath =
- StringUtils.join( modulePathElements.iterator(), File.pathSeparator );
- addArgIfNotEmpty( arguments, "--module-path", JavadocUtil.quotedPathArgument( modulepath ) );
- }
- catch ( IOException e )
- {
- throw new MavenReportException( e.getMessage(), e );
- }
- }
- else
- {
- String classpath = StringUtils.join( getPathElements().iterator(), File.pathSeparator );
- addArgIfNotEmpty( arguments, "-classpath", JavadocUtil.quotedPathArgument( classpath ) );
- }
-
Collection<String> reactorKeys = new HashSet<>( session.getProjects().size() );
for ( MavenProject reactorProject : session.getProjects() )
{
@@ -4731,6 +4692,10 @@
reactorProject.getArtifactId() ) );
}
+ final LocationManager locationManager = new LocationManager();
+
+ Collection<String> additionalModules = new ArrayList<>();
+
Path moduleSourceDir = null;
if ( allSourcePaths.size() > 1 )
{
@@ -4752,6 +4717,8 @@
String moduleName =
locationManager.resolvePaths( request ).getMainModuleDescriptor().name();
+ additionalModules.add( moduleName );
+
addArgIfNotEmpty( arguments, "--patch-module", moduleName + '='
+ JavadocUtil.quotedPathArgument( getSourcePath( projectSourcepaths.getValue() ) ) );
@@ -4776,6 +4743,62 @@
}
}
}
+
+ List<String> roots = getProjectSourceRoots( getProject() );
+
+ File mainDescriptor = findMainDescriptor( roots );
+
+ if ( javadocRuntimeVersion.isAtLeast( "9" ) && ( isAggregator() || mainDescriptor != null ) && !isTest() )
+ {
+ ResolvePathsRequest<File> request =
+ ResolvePathsRequest.withFiles( getPathElements() ).setAdditionalModules( additionalModules );
+
+ if ( mainDescriptor != null )
+ {
+ request.setMainModuleDescriptor( mainDescriptor );
+ }
+
+ try
+ {
+ ResolvePathsResult<File> result = locationManager.resolvePaths( request );
+
+ Set<File> modulePathElements = new HashSet<>( result.getModulepathElements().keySet() ) ;
+ if ( allSourcePaths.size() > 1 )
+ {
+ // Probably required due to bug in javadoc (Java 9+)
+ modulePathElements.addAll( getProjectBuildOutputDirs( getProject() ) );
+ }
+
+ Collection<File> classPathElements = new ArrayList<>( result.getClasspathElements().size() );
+ for ( File file : result.getClasspathElements() )
+ {
+ if ( file.isDirectory() && new File( file, "module-info.class" ).exists() )
+ {
+ modulePathElements.add( file );
+ }
+ else
+ {
+ classPathElements.add( file );
+ }
+ }
+
+ String classpath = StringUtils.join( classPathElements.iterator(), File.pathSeparator );
+ addArgIfNotEmpty( arguments, "--class-path", JavadocUtil.quotedPathArgument( classpath ) );
+
+ String modulepath =
+ StringUtils.join( modulePathElements.iterator(), File.pathSeparator );
+ addArgIfNotEmpty( arguments, "--module-path", JavadocUtil.quotedPathArgument( modulepath ) );
+ }
+ catch ( IOException e )
+ {
+ throw new MavenReportException( e.getMessage(), e );
+ }
+ }
+ else
+ {
+ String classpath = StringUtils.join( getPathElements().iterator(), File.pathSeparator );
+ addArgIfNotEmpty( arguments, "-classpath", JavadocUtil.quotedPathArgument( classpath ) );
+ }
if ( StringUtils.isNotEmpty( doclet ) )
{