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/15 13:58:13 UTC
[maven-javadoc-plugin] branch master updated: [MJAVADOC-568]
javadoc:jar fails when project has Automatic-Module-Name and (implicit)
uses offlinelinks with element-list Reduce change of split packages
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
The following commit(s) were added to refs/heads/master by this push:
new f09e0c8 [MJAVADOC-568] javadoc:jar fails when project has Automatic-Module-Name and (implicit) uses offlinelinks with element-list Reduce change of split packages
f09e0c8 is described below
commit f09e0c8a6563f505a5e1bd5862952d00458cdb5d
Author: rfscholte <rf...@apache.org>
AuthorDate: Fri Feb 15 14:58:05 2019 +0100
[MJAVADOC-568] javadoc:jar fails when project has Automatic-Module-Name and (implicit) uses offlinelinks with element-list
Reduce change of split packages
---
.../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 | 41 +++++++-----
.../apache/maven/plugins/javadoc/JavadocUtil.java | 4 +-
.../AggregateResourcesTestMavenProjectStub.java | 8 +++
.../stubs/AggregateTestMavenProjectStub.java | 9 +++
11 files changed, 327 insertions(+), 20 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 75c8695..3fc50bf 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -2243,10 +2243,10 @@ public abstract class AbstractJavadocMojo
}
/**
- * Method to get the source paths. If no source path is specified in the parameter, the compile source roots
- * of the project will be used.
+ * Method to get the source paths per reactorProject. If no source path is specified in the parameter, the compile
+ * source roots of the project will be used.
*
- * @return a Collection of the project absolute source paths as <code>String</code>
+ * @return a Map of the project absolute source paths per projects key (G:A)
* @throws MavenReportException {@link MavenReportException}
* @see JavadocUtil#pruneDirs(MavenProject, Collection)
*/
@@ -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,18 @@ public abstract class AbstractJavadocMojo
ResolvePathsResult<File> result = locationManager.resolvePaths( request );
Set<File> modulePathElements = new HashSet<>( result.getModulepathElements().keySet() ) ;
- 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 +5135,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/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
index 8c4f4f9..7eb9f92 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -81,6 +81,7 @@ import java.nio.charset.IllegalCharsetNameException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
@@ -180,8 +181,7 @@ public class JavadocUtil
{
if ( f != null )
{
- File file = new File( f );
- if ( file.isFile() && ( isEmpty( pruned ) || !pruned.contains( f ) ) )
+ if ( Files.isRegularFile( Paths.get( f ) ) && !pruned.contains( f ) )
{
return false;
}
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();
+ }
}