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/16 09:38:21 UTC

[maven-javadoc-plugin] branch MJAVADOC-568 created (now 5250cba)

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 5250cba  [MJAVADOC] Improve split package issue with Manifest base modules.

This branch includes the following new commits:

     new 5250cba  [MJAVADOC] Improve split package issue with Manifest base modules.

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] Improve split package issue with Manifest base modules.

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 5250cba293ca561b59e4e5738e3dffd48dc85c5a
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Feb 16 10:38:15 2019 +0100

    [MJAVADOC] Improve split package issue with Manifest base modules.
---
 .../mojo/pom.xml                                   |  6 +++
 .../mojo/src/main/java/mojo/TestcaseMojo.java      |  6 +++
 .../maven/plugins/javadoc/AbstractJavadocMojo.java | 61 ++++++++++++++++------
 3 files changed, 56 insertions(+), 17 deletions(-)

diff --git a/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/pom.xml b/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/pom.xml
index 5032cc5..67b08dc 100644
--- a/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/pom.xml
+++ b/src/it/projects/MJAVADOC-568_manifest-splitpackage/mojo/pom.xml
@@ -53,9 +53,15 @@
       <version>3.6.0</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</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>
+      <optional>true</optional>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.plugins.javadoc.it</groupId>
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
index e50c6fb..998be61 100644
--- 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
@@ -23,6 +23,8 @@ import normal.Testcase;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
 
 /**
  * This is also a comment.
@@ -30,6 +32,10 @@ import org.apache.maven.plugins.annotations.Mojo;
 @Mojo(name = "my-mojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
 public class TestcaseMojo extends AbstractMojo
 {
+    
+    @Parameter( defaultValue="${project}", readonly=true, required = true )
+    private MavenProject project;
+    
 	public Testcase createTestcase()
 	{
 		return null;
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 3fc50bf..3177dc5 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -4949,6 +4949,8 @@ public abstract class AbstractJavadocMojo
 
         ResolvePathResult mainResolvePathResult = null;
         
+        Map<String, Collection<Path>> patchModules = new HashMap<>();
+        
         Path moduleSourceDir = null;
         if ( supportModulePath && !allModuleDescriptors.isEmpty() )
         {
@@ -5008,9 +5010,7 @@ public abstract class AbstractJavadocMojo
 
                             additionalModules.add( result.getModuleDescriptor().name() );
 
-                            addArgIfNotEmpty( arguments, "--patch-module", result.getModuleDescriptor().name() + '='
-                                 + JavadocUtil.quotedPathArgument( getSourcePath( projectSourcepaths.getValue() ) ),
-                                   false, false );
+                            patchModules.put( result.getModuleDescriptor().name(), projectSourcepaths.getValue() );
                             
                             Path modulePath = moduleSourceDir.resolve( result.getModuleDescriptor().name() );
                             if ( !Files.isDirectory( modulePath ) )
@@ -5072,11 +5072,21 @@ public abstract class AbstractJavadocMojo
             }
         }
         
+        final ModuleNameSource mainModuleNameSource;
+        if ( mainResolvePathResult != null )
+        {
+            mainModuleNameSource = mainResolvePathResult.getModuleNameSource();
+        }
+        else
+        {
+            mainModuleNameSource = null;
+        }
+        
         if ( supportModulePath
-            && ( isAggregator() || ( mainResolvePathResult != null
-                && ( ModuleNameSource.MODULEDESCRIPTOR.equals( mainResolvePathResult.getModuleNameSource() ) 
-                     || ModuleNameSource.MANIFEST.equals( mainResolvePathResult.getModuleNameSource() ) ) ) )
-            && !isTest() )
+             && !isTest()
+             && ( isAggregator()
+                  || ModuleNameSource.MODULEDESCRIPTOR.equals( mainModuleNameSource )
+                  || ModuleNameSource.MANIFEST.equals( mainModuleNameSource ) ) )
         {
             List<File> pathElements = new ArrayList<>( getPathElements() );
             File artifactFile = getArtifactFile( project );
@@ -5088,9 +5098,11 @@ public abstract class AbstractJavadocMojo
             ResolvePathsRequest<File> request =
                 ResolvePathsRequest.ofFiles( pathElements );
 
+            String mainModuleName = null;
             if ( mainResolvePathResult != null )
             {
                 request.setModuleDescriptor( mainResolvePathResult.getModuleDescriptor() );
+                mainModuleName = mainResolvePathResult.getModuleDescriptor().name();
             }
             
             request.setAdditionalModules( additionalModules );
@@ -5101,26 +5113,34 @@ public abstract class AbstractJavadocMojo
                 
                 Set<File> modulePathElements = new HashSet<>( result.getModulepathElements().keySet() )  ;
                 
-                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 ( directDependencyArtifactFiles.contains( file )
-                        || ( file.isDirectory() && new File( file, "module-info.class" ).exists() ) )
+                    if ( file.isDirectory() && new File( file, "module-info.class" ).exists() )
                     {
                         modulePathElements.add( file );
                     }
+                    else if ( ModuleNameSource.MANIFEST.equals( mainModuleNameSource ) )
+                    {
+                        ModuleNameSource depModuleNameSource =
+                            locationManager.resolvePath( ResolvePathRequest.ofFile( file ) ).getModuleNameSource();
+                        if ( ModuleNameSource.MODULEDESCRIPTOR.equals( depModuleNameSource )
+                            || ModuleNameSource.MANIFEST.equals( depModuleNameSource ) )
+                        {
+                            modulePathElements.add( file );
+                        }
+                        else
+                        {
+                            patchModules.get( mainModuleName ).add( file.toPath() );
+                        }
+                    }
                     else
                     {
                         classPathElements.add( file );
                     }
                 }
-                
+
                 String classpath = StringUtils.join( classPathElements.iterator(), File.pathSeparator );
                 addArgIfNotEmpty( arguments, "--class-path", JavadocUtil.quotedPathArgument( classpath ), false,
                                   false );
@@ -5145,7 +5165,14 @@ public abstract class AbstractJavadocMojo
             String classpath = StringUtils.join( getPathElements().iterator(), File.pathSeparator );
             addArgIfNotEmpty( arguments, "-classpath", JavadocUtil.quotedPathArgument( classpath ) , false, false );
         }
-        
+
+        for ( Entry<String, Collection<Path>> entry : patchModules.entrySet() )
+        {
+            addArgIfNotEmpty( arguments, "--patch-module", entry.getKey() + '='
+                              + JavadocUtil.quotedPathArgument( getSourcePath( entry.getValue() ) ),
+                                false, false );
+        }
+
         if ( StringUtils.isNotEmpty( doclet ) )
         {
             addArgIfNotEmpty( arguments, "-doclet", JavadocUtil.quotedArgument( doclet ) );