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 2019/02/14 20:11:38 UTC

[maven-javadoc-plugin] branch MJAVADOC-568 created (now 59bb803)

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

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


      at 59bb803  [MJAVADOC-568] javadoc:jar fails when project has Automatic-Module-Name and (implicit) uses offlinelinks with element-list

This branch includes the following new commits:

     new 59bb803  [MJAVADOC-568] javadoc:jar fails when project has Automatic-Module-Name and (implicit) uses offlinelinks with element-list

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



[maven-javadoc-plugin] 01/01: [MJAVADOC-568] javadoc:jar fails when project has Automatic-Module-Name and (implicit) uses offlinelinks with element-list

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

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

commit 59bb80346605b9b1a5aefc92703dececa46a9dab
Author: rfscholte <rf...@apache.org>
AuthorDate: Thu Feb 14 21:11:28 2019 +0100

    [MJAVADOC-568] javadoc:jar fails when project has Automatic-Module-Name and (implicit) uses offlinelinks with element-list
---
 .../invoker.properties                             | 18 +++++
 .../java-module/pom.xml                            | 34 ++++++++++
 .../java-module/src/main/java/module-info.java     | 22 +++++++
 .../java-module/src/main/java/normal/Testcase.java | 27 ++++++++
 .../mojo/pom.xml                                   | 66 +++++++++++++++++++
 .../mojo/src/main/java/mojo/TestcaseMojo.java      | 42 ++++++++++++
 .../MJAVADOC-568_manifest-splitpackage/pom.xml     | 76 ++++++++++++++++++++++
 .../maven/plugins/javadoc/AbstractJavadocMojo.java | 36 +++++-----
 .../AggregateResourcesTestMavenProjectStub.java    |  8 +++
 .../stubs/AggregateTestMavenProjectStub.java       |  9 +++
 10 files changed, 323 insertions(+), 15 deletions(-)

diff --git a/src/it/projects/MJAVADOC-568_manifest-splitpackage/invoker.properties b/src/it/projects/MJAVADOC-568_manifest-splitpackage/invoker.properties
new file mode 100644
index 0000000..538618d
--- /dev/null
+++ b/src/it/projects/MJAVADOC-568_manifest-splitpackage/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+
+invoker.goals = package
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-568_manifest-splitpackage/java-module/pom.xml b/src/it/projects/MJAVADOC-568_manifest-splitpackage/java-module/pom.xml
new file mode 100644
index 0000000..0b8f9ea
--- /dev/null
+++ b/src/it/projects/MJAVADOC-568_manifest-splitpackage/java-module/pom.xml
@@ -0,0 +1,34 @@
+<?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>mjavadoc568</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>java-module</artifactId>
+
+</project>
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-568_manifest-splitpackage/java-module/src/main/java/module-info.java b/src/it/projects/MJAVADOC-568_manifest-splitpackage/java-module/src/main/java/module-info.java
new file mode 100644
index 0000000..614dc1f
--- /dev/null
+++ b/src/it/projects/MJAVADOC-568_manifest-splitpackage/java-module/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 normal {
+	exports normal to mojo;
+}
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-568_manifest-splitpackage/java-module/src/main/java/normal/Testcase.java b/src/it/projects/MJAVADOC-568_manifest-splitpackage/java-module/src/main/java/normal/Testcase.java
new file mode 100644
index 0000000..99e4386
--- /dev/null
+++ b/src/it/projects/MJAVADOC-568_manifest-splitpackage/java-module/src/main/java/normal/Testcase.java
@@ -0,0 +1,27 @@
+package normal;
+
+/*
+ * 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.
+ */
+
+/**
+ * This is a comment.
+ */
+public class Testcase
+{
+}
diff --git a/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/pom.xml b/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/pom.xml
new file mode 100644
index 0000000..5032cc5
--- /dev/null
+++ b/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/pom.xml
@@ -0,0 +1,66 @@
+<?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>mjavadoc568</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>mojo</artifactId>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>mojo</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>3.6.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.6.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugins.javadoc.it</groupId>
+      <artifactId>java-module</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/src/main/java/mojo/TestcaseMojo.java b/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/src/main/java/mojo/TestcaseMojo.java
new file mode 100644
index 0000000..e50c6fb
--- /dev/null
+++ b/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/src/main/java/mojo/TestcaseMojo.java
@@ -0,0 +1,42 @@
+package mojo;
+
+/*
+ * 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.
+ */
+
+import normal.Testcase;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * This is also a comment.
+ */
+@Mojo(name = "my-mojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
+public class TestcaseMojo extends AbstractMojo
+{
+	public Testcase createTestcase()
+	{
+		return null;
+	}
+
+	@Override
+	public void execute()
+	{
+	}
+}
diff --git a/src/it/projects/MJAVADOC-568_manifest-splitpackage/pom.xml b/src/it/projects/MJAVADOC-568_manifest-splitpackage/pom.xml
new file mode 100644
index 0000000..52c4a70
--- /dev/null
+++ b/src/it/projects/MJAVADOC-568_manifest-splitpackage/pom.xml
@@ -0,0 +1,76 @@
+<?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>org.apache.maven.plugins.javadoc.it</groupId>
+  <artifactId>mjavadoc568</artifactId>
+  <packaging>pom</packaging>
+  <version>1.0-SNAPSHOT</version>
+  
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-jar-plugin</artifactId>
+          <version>3.1.0</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.8.0</version>
+          <configuration>
+            <release>9</release>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-javadoc-plugin</artifactId>
+          <version>@project.version@</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <modules>
+    <module>java-module</module>
+    <module>mojo</module>
+  </modules>
+</project>
\ No newline at end of file
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 434c148..43942ff 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -2657,10 +2657,10 @@ public abstract class AbstractJavadocMojo
      * @return all classpath elements
      * @throws MavenReportException if any.
      */
-    private List<File> getPathElements()
+    private Collection<File> getPathElements()
         throws MavenReportException
     {
-        List<File> classpathElements = new ArrayList<>();
+        Set<File> classpathElements = new LinkedHashSet<>();
         Map<String, Artifact> compileArtifactMap = new LinkedHashMap<>();
 
         if ( isTest() )
@@ -2669,7 +2669,6 @@ public abstract class AbstractJavadocMojo
         }
         
         populateCompileArtifactMap( compileArtifactMap, project.getArtifacts() );
-
         
         if ( isAggregator() )
         {
@@ -5075,11 +5074,19 @@ public abstract class AbstractJavadocMojo
         
         if ( supportModulePath
             && ( isAggregator() || ( mainResolvePathResult != null
-                && ModuleNameSource.MODULEDESCRIPTOR.equals( mainResolvePathResult.getModuleNameSource() ) ) )
+                && ( ModuleNameSource.MODULEDESCRIPTOR.equals( mainResolvePathResult.getModuleNameSource() ) 
+                     || ModuleNameSource.MANIFEST.equals( mainResolvePathResult.getModuleNameSource() ) ) ) )
             && !isTest() )
         {
+            List<File> pathElements = new ArrayList<>( getPathElements() );
+            File artifactFile = getArtifactFile( project );
+            if ( artifactFile != null )
+            {
+                pathElements.add( 0, artifactFile );
+            }
+            
             ResolvePathsRequest<File> request =
-                ResolvePathsRequest.ofFiles( getPathElements() );
+                ResolvePathsRequest.ofFiles( pathElements );
 
             if ( mainResolvePathResult != null )
             {
@@ -5093,12 +5100,19 @@ public abstract class AbstractJavadocMojo
                 ResolvePathsResult<File> result = locationManager.resolvePaths( request );
                 
                 Set<File> modulePathElements = new HashSet<>( result.getModulepathElements().keySet() )  ;
-                modulePathElements.addAll( getProjectBuildOutputDirs( getProject() ) );
+                modulePathElements.addAll( getProjectBuildOutputDirs( getProject() ) ); // ???
+                
+                Set<File> directDependencyArtifactFiles = new HashSet<>( project.getDependencyArtifacts().size() );
+                for ( Artifact depArt : project.getDependencyArtifacts() )
+                {
+                    directDependencyArtifactFiles.add( depArt.getFile() );
+                }
 
                 Collection<File> classPathElements = new ArrayList<>( result.getClasspathElements().size() );
                 for ( File file : result.getClasspathElements() )
                 {
-                    if ( file.isDirectory() && new File( file, "module-info.class" ).exists() )
+                    if ( directDependencyArtifactFiles.contains( file )
+                        || ( file.isDirectory() && new File( file, "module-info.class" ).exists() ) )
                     {
                         modulePathElements.add( file );
                     }
@@ -5122,14 +5136,6 @@ public abstract class AbstractJavadocMojo
                 throw new MavenReportException( e.getMessage(), e );
             }
         }
-        else if ( supportModulePath && ( mainResolvePathResult != null
-            && ModuleNameSource.MANIFEST.equals( mainResolvePathResult.getModuleNameSource() ) ) && !isTest() )
-        {
-            List<File> modulePathFiles = new ArrayList<>( getPathElements() );
-            modulePathFiles.add( project.getArtifact().getFile() );
-            String modulepath = StringUtils.join( modulePathFiles.iterator(), File.pathSeparator );
-            addArgIfNotEmpty( arguments, "--module-path", JavadocUtil.quotedPathArgument( modulepath ) , false, false );
-        }
         else if ( supportModulePath && moduleDescriptorSource && !isTest() )
         {
             String modulepath = StringUtils.join( getPathElements().iterator(), File.pathSeparator );
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/stubs/AggregateResourcesTestMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/javadoc/stubs/AggregateResourcesTestMavenProjectStub.java
index 39ffa57..4d1c5e5 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/stubs/AggregateResourcesTestMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/stubs/AggregateResourcesTestMavenProjectStub.java
@@ -22,8 +22,11 @@ package org.apache.maven.plugins.javadoc.stubs;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Build;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.MavenProject;
@@ -75,4 +78,9 @@ public class AggregateResourcesTestMavenProjectStub
         return Arrays.asList( "project1", "project2" );
     }
 
+    @Override
+    public Set<Artifact> getDependencyArtifacts()
+    {
+        return Collections.emptySet();
+    }
 }
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/stubs/AggregateTestMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/javadoc/stubs/AggregateTestMavenProjectStub.java
index 5d0e1eb..f4a4521 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/stubs/AggregateTestMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/stubs/AggregateTestMavenProjectStub.java
@@ -22,8 +22,11 @@ package org.apache.maven.plugins.javadoc.stubs;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Build;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.MavenProject;
@@ -86,4 +89,10 @@ public class AggregateTestMavenProjectStub
     {
         return Arrays.asList( "project1", "project2" );
     }
+    
+    @Override
+    public Set<Artifact> getDependencyArtifacts()
+    {
+        return Collections.emptySet();
+    }
 }