You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/20 09:16:42 UTC
[maven-javadoc-plugin] 11/13: [MJAVADOC-498] "module not found"
when Java 9 module-info present Support aggrated javadoc
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to branch master2
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit 8023d89be9bac9088128e25bdc02d7c34823f1ec
Author: Robert Scholte <rf...@apache.org>
AuthorDate: Sun Dec 3 16:02:59 2017 +0000
[MJAVADOC-498] "module not found" when Java 9 module-info present
Support aggrated javadoc
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1817039 13f79535-47bb-0310-9956-ffa450edef68
---
.../MJAVADOC-498_aggr_modulepath/bar/pom.xml | 41 +++++++++
.../bar/src/main/java/com/bar/OtherClass.java | 25 ++++++
.../bar/src/main/java/module-info.java | 25 ++++++
.../MJAVADOC-498_aggr_modulepath/baz/pom.xml | 61 ++++++++++++++
.../baz/src/main/java/com/baz/LonelyClass.java | 25 ++++++
.../baz/src/main/java/module-info.java | 25 ++++++
.../MJAVADOC-498_aggr_modulepath/foo/pom.xml | 32 ++++++++
.../foo/src/main/java/com/foo/MyClass.java | 25 ++++++
.../foo/src/main/java/module-info.java | 22 +++++
.../invoker.properties | 18 ++++
.../projects/MJAVADOC-498_aggr_modulepath/pom.xml | 68 +++++++++++++++
.../maven/plugins/javadoc/AbstractJavadocMojo.java | 96 +++++++++++++++++++---
.../javadoc/AggregatorJavadocReportTest.java | 7 +-
.../maven/plugins/javadoc/FixJavadocMojoTest.java | 2 +-
.../maven/plugins/javadoc/JavadocJarTest.java | 8 ++
.../maven/plugins/javadoc/JavadocReportTest.java | 14 +++-
.../plugins/javadoc/TestJavadocReportTest.java | 9 +-
17 files changed, 485 insertions(+), 18 deletions(-)
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/bar/pom.xml b/src/it/projects/MJAVADOC-498_aggr_modulepath/bar/pom.xml
new file mode 100644
index 0000000..6c807c4
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/bar/pom.xml
@@ -0,0 +1,41 @@
+<?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>
+ <parent>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc489</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>bar</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>foo</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/bar/src/main/java/com/bar/OtherClass.java b/src/it/projects/MJAVADOC-498_aggr_modulepath/bar/src/main/java/com/bar/OtherClass.java
new file mode 100644
index 0000000..dcfc6ed
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/bar/src/main/java/com/bar/OtherClass.java
@@ -0,0 +1,25 @@
+package com.bar;
+
+/*
+ * 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.
+ */
+
+public class OtherClass
+{
+ private com.foo.MyClass myClass;
+}
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/bar/src/main/java/module-info.java b/src/it/projects/MJAVADOC-498_aggr_modulepath/bar/src/main/java/module-info.java
new file mode 100644
index 0000000..b9fe87f
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/bar/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.
+ */
+module com.bar
+{
+ requires com.foo;
+
+ // workaround javadoc bug;
+ exports com.bar;
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/baz/pom.xml b/src/it/projects/MJAVADOC-498_aggr_modulepath/baz/pom.xml
new file mode 100644
index 0000000..0a63d7c
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/baz/pom.xml
@@ -0,0 +1,61 @@
+<?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>
+ <parent>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc489</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>baz</artifactId>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>javadoc-aggregate</id>
+ <phase>package</phase>
+ <goals>
+ <goal>javadoc-no-fork</goal>
+ </goals>
+ <configuration>
+ <includeDependencySources>true</includeDependencySources>
+ <includeTransitiveDependencySources>true</includeTransitiveDependencySources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>bar</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/baz/src/main/java/com/baz/LonelyClass.java b/src/it/projects/MJAVADOC-498_aggr_modulepath/baz/src/main/java/com/baz/LonelyClass.java
new file mode 100644
index 0000000..7677263
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/baz/src/main/java/com/baz/LonelyClass.java
@@ -0,0 +1,25 @@
+package com.baz;
+
+/*
+ * 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.
+ */
+
+public class LonelyClass
+{
+
+}
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/baz/src/main/java/module-info.java b/src/it/projects/MJAVADOC-498_aggr_modulepath/baz/src/main/java/module-info.java
new file mode 100644
index 0000000..3df87ee
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/baz/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.
+ */
+module com.baz
+{
+ requires com.bar;
+
+ // workaround javadoc bug;
+ exports com.baz;
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/foo/pom.xml b/src/it/projects/MJAVADOC-498_aggr_modulepath/foo/pom.xml
new file mode 100644
index 0000000..3f07a01
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/foo/pom.xml
@@ -0,0 +1,32 @@
+<?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">
+
+ <parent>
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc489</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>foo</artifactId>
+
+</project>
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/foo/src/main/java/com/foo/MyClass.java b/src/it/projects/MJAVADOC-498_aggr_modulepath/foo/src/main/java/com/foo/MyClass.java
new file mode 100644
index 0000000..dae085a
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/foo/src/main/java/com/foo/MyClass.java
@@ -0,0 +1,25 @@
+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.
+ */
+
+public class MyClass
+{
+
+}
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/foo/src/main/java/module-info.java b/src/it/projects/MJAVADOC-498_aggr_modulepath/foo/src/main/java/module-info.java
new file mode 100644
index 0000000..ed1b6bf
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/foo/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;
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/invoker.properties b/src/it/projects/MJAVADOC-498_aggr_modulepath/invoker.properties
new file mode 100644
index 0000000..9511718
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/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 = 9+
diff --git a/src/it/projects/MJAVADOC-498_aggr_modulepath/pom.xml b/src/it/projects/MJAVADOC-498_aggr_modulepath/pom.xml
new file mode 100644
index 0000000..aa3813c
--- /dev/null
+++ b/src/it/projects/MJAVADOC-498_aggr_modulepath/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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+ <artifactId>mjavadoc489</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <url>https://issues.apache.org/jira/browse/MJAVADOC-489</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <modules>
+ <module>foo</module>
+ <module>bar</module>
+ <module>baz</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.7.0</version>
+ <configuration>
+ <release>9</release>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</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 b850eac..91abfad 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -38,6 +38,8 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -1899,7 +1901,6 @@ public abstract class AbstractJavadocMojo
public void execute()
throws MojoExecutionException, MojoFailureException
{
- getLog().debug( "verify removed parameter" );
verifyRemovedParameter( "aggregator" );
verifyRemovedParameter( "proxyHost" );
verifyRemovedParameter( "proxyPort" );
@@ -2062,7 +2063,7 @@ public abstract class AbstractJavadocMojo
// Wrap Javadoc options
// ----------------------------------------------------------------------
- addJavadocOptions( arguments, sourcePaths );
+ addJavadocOptions( javadocOutputDirectory, arguments, sourcePaths );
// ----------------------------------------------------------------------
// Wrap Standard doclet Options
@@ -2232,8 +2233,8 @@ public abstract class AbstractJavadocMojo
if ( StringUtils.isEmpty( sourcepath ) )
{
- Collection<String> sourcePaths =
- new ArrayList<>( JavadocUtil.pruneDirs( project, getProjectSourceRoots( project ) ) );
+ Set<String> sourcePaths =
+ new LinkedHashSet<>( JavadocUtil.pruneDirs( project, getProjectSourceRoots( project ) ) );
if ( project.getExecutionProject() != null )
{
@@ -4638,12 +4639,15 @@ public abstract class AbstractJavadocMojo
* The <a href="package-summary.html#Standard_Javadoc_Options">package documentation</a> details the
* Standard Javadoc Options wrapped by this Plugin.
*
+ * @param javadocOutputDirectory not null
* @param arguments not null
* @param sourcePaths not null
* @throws MavenReportException if any
* @see <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#javadocoptions">http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#javadocoptions</a>
*/
- private void addJavadocOptions( List<String> arguments, Map<String, Collection<String>> allSourcePaths )
+ private void addJavadocOptions( File javadocOutputDirectory,
+ List<String> arguments,
+ Map<String, Collection<String>> allSourcePaths )
throws MavenReportException
{
Collection<String> sourcePaths = collect( allSourcePaths.values() );
@@ -4677,10 +4681,11 @@ public abstract class AbstractJavadocMojo
List<String> roots = getProjectSourceRoots( getProject() );
File mainDescriptor = findMainDescriptor( roots );
-
+
+ final LocationManager locationManager = new LocationManager();
+
if ( mainDescriptor != null && !isTest() )
{
- LocationManager locationManager = new LocationManager();
ResolvePathsRequest<File> request =
ResolvePathsRequest.withFiles( getPathElements() ).setMainModuleDescriptor( mainDescriptor );
try
@@ -4690,9 +4695,15 @@ public abstract class AbstractJavadocMojo
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( result.getModulepathElements().keySet().iterator(), File.pathSeparator );
- getLog().info( "modulepath: " + modulepath );
+ StringUtils.join( modulePathElements.iterator(), File.pathSeparator );
addArgIfNotEmpty( arguments, "--module-path", JavadocUtil.quotedPathArgument( modulepath ) );
}
catch ( IOException e )
@@ -4706,6 +4717,59 @@ public abstract class AbstractJavadocMojo
addArgIfNotEmpty( arguments, "-classpath", JavadocUtil.quotedPathArgument( classpath ) );
}
+ Collection<String> reactorKeys = new HashSet<>( session.getProjects().size() );
+ for ( MavenProject reactorProject : session.getProjects() )
+ {
+ reactorKeys.add( ArtifactUtils.versionlessKey( reactorProject.getGroupId(),
+ reactorProject.getArtifactId() ) );
+ }
+
+ Path moduleSourceDir = null;
+ if ( allSourcePaths.size() > 1 )
+ {
+ for ( Map.Entry<String, Collection<String>> projectSourcepaths : allSourcePaths.entrySet() )
+ {
+ if ( reactorKeys.contains( projectSourcepaths.getKey() ) )
+ {
+ File moduleDescriptor = findMainDescriptor( projectSourcepaths.getValue() );
+ if ( moduleDescriptor != null )
+ {
+ moduleSourceDir = javadocOutputDirectory.toPath().resolve( "src" );
+ try
+ {
+ moduleSourceDir = Files.createDirectories( moduleSourceDir );
+ ResolvePathsRequest<File> request =
+ ResolvePathsRequest.withFiles( Collections.<File>emptyList() )
+ .setMainModuleDescriptor( moduleDescriptor );
+
+ String moduleName =
+ locationManager.resolvePaths( request ).getMainModuleDescriptor().name();
+
+ addArgIfNotEmpty( arguments, "--patch-module", moduleName + '='
+ + JavadocUtil.quotedPathArgument( getSourcePath( projectSourcepaths.getValue() ) ) );
+
+ Files.createDirectory( moduleSourceDir.resolve( moduleName ) );
+ }
+ catch ( IOException e )
+ {
+ throw new MavenReportException( e.getMessage() );
+ }
+ }
+ else
+ {
+ // todo
+ getLog().error( "no module descriptor for " + projectSourcepaths.getKey() );
+ }
+ }
+ else
+ {
+ // todo
+ getLog().error( "no reactor project: " + projectSourcepaths.getKey() );
+
+ }
+ }
+ }
+
if ( StringUtils.isNotEmpty( doclet ) )
{
addArgIfNotEmpty( arguments, "-doclet", JavadocUtil.quotedArgument( doclet ) );
@@ -4743,7 +4807,17 @@ public abstract class AbstractJavadocMojo
sourcepath = StringUtils.join( sourcePaths.iterator(), File.pathSeparator );
}
- addArgIfNotEmpty( arguments, "-sourcepath", JavadocUtil.quotedPathArgument( getSourcePath( sourcePaths ) ) );
+ if ( moduleSourceDir != null )
+ {
+ addArgIfNotEmpty( arguments, "--module-source-path",
+ JavadocUtil.quotedPathArgument( moduleSourceDir.toString() ) );
+ }
+ else
+ {
+ addArgIfNotEmpty( arguments, "-sourcepath",
+ JavadocUtil.quotedPathArgument( getSourcePath( sourcePaths ) ) );
+ }
+
if ( StringUtils.isNotEmpty( sourcepath ) && isJavaDocVersionAtLeast( SINCE_JAVADOC_1_5 ) )
{
@@ -4764,7 +4838,7 @@ public abstract class AbstractJavadocMojo
}
}
- private File findMainDescriptor( List<String> roots )
+ private File findMainDescriptor( Collection<String> roots )
{
for ( String root : roots )
{
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReportTest.java b/src/test/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReportTest.java
index bc94fcd..706b26e 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReportTest.java
@@ -30,6 +30,7 @@ import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
import org.sonatype.aether.util.DefaultRepositorySystemSession;
@@ -68,7 +69,11 @@ public class AggregatorJavadocReportTest
MojoExecution mojoExec = new MojoExecution( new Plugin(), "aggregate", null );
setVariableValueToObject( mojo, "mojo", mojoExec );
- MavenSession session = newMavenSession( new MavenProjectStub() );
+ MavenProject currentProject = new MavenProjectStub();
+ currentProject.setGroupId( "GROUPID" );
+ currentProject.setArtifactId( "ARTIFACTID" );
+
+ MavenSession session = newMavenSession( currentProject );
DefaultRepositorySystemSession repoSysSession = (DefaultRepositorySystemSession) session.getRepositorySession();
repoSysSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepo ) );
setVariableValueToObject( mojo, "session", session );
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java b/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
index c2866d6..9578f58 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
@@ -150,7 +150,7 @@ public class FixJavadocMojoTest
{
// Should be an assumption, but not supported by TestCase
// Java 5 not supported by Java9 anymore
- if ( JavadocVersion.parse( SystemUtils.JAVA_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 )
+ if ( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 )
{
return;
}
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
index 2ecd5d5..e066e47 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
@@ -32,9 +32,11 @@ import java.util.zip.ZipFile;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.plugins.javadoc.AbstractJavadocMojo;
import org.apache.maven.plugins.javadoc.JavadocJar;
import org.apache.maven.plugins.javadoc.JavadocVersion;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
/**
@@ -53,6 +55,12 @@ public class JavadocJarTest
setVariableValueToObject( mojo, "mojo", mojoExec );
+ MavenProject currentProject = new MavenProjectStub();
+ currentProject.setGroupId( "GROUPID" );
+ currentProject.setArtifactId( "ARTIFACTID" );
+
+ setVariableValueToObject( mojo, "session", newMavenSession( currentProject ) );
+
return mojo;
}
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
index 24643b4..19d6fa9 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
@@ -38,9 +38,9 @@ import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugins.javadoc.JavadocReport;
-import org.apache.maven.plugins.javadoc.JavadocVersion;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.plugins.javadoc.ProxyServer.AuthAsyncProxyServlet;
+import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.apache.maven.settings.Proxy;
@@ -93,6 +93,12 @@ public class JavadocReportTest
setVariableValueToObject( mojo, "mojo", mojoExec );
+ MavenProject currentProject = new MavenProjectStub();
+ currentProject.setGroupId( "GROUPID" );
+ currentProject.setArtifactId( "ARTIFACTID" );
+
+ setVariableValueToObject( mojo, "session", newMavenSession( currentProject ) );
+
return mojo;
}
@@ -299,7 +305,7 @@ public class JavadocReportTest
{
// Should be an assumption, but not supported by TestCase
// Seems like a bug in Javadoc 9
- if ( JavadocVersion.parse( SystemUtils.JAVA_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) == 0 )
+ if ( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) == 0 )
{
return;
}
@@ -562,7 +568,7 @@ public class JavadocReportTest
{
// Should be an assumption, but not supported by TestCase
// Java 5 not supported by Java9 anymore
- if ( JavadocVersion.parse( SystemUtils.JAVA_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 )
+ if ( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 )
{
return;
}
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/TestJavadocReportTest.java b/src/test/java/org/apache/maven/plugins/javadoc/TestJavadocReportTest.java
index 047b754..7ada0da 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/TestJavadocReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/TestJavadocReportTest.java
@@ -24,7 +24,8 @@ import java.io.File;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugins.javadoc.TestJavadocReport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
/**
@@ -49,7 +50,13 @@ public class TestJavadocReportTest
MojoExecution mojoExec = new MojoExecution( new Plugin(), "test-javadoc", null );
setVariableValueToObject( mojo, "mojo", mojoExec );
+
+ MavenProject currentProject = new MavenProjectStub();
+ currentProject.setGroupId( "GROUPID" );
+ currentProject.setArtifactId( "ARTIFACTID" );
+ setVariableValueToObject( mojo, "session", newMavenSession( currentProject ) );
+
mojo.execute();
File generatedFile =
--
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.