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 2021/08/29 10:35:34 UTC

[maven-javadoc-plugin] branch MJAVADOC-618 updated (c8ce778 -> e86301e)

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

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


    from c8ce778  null or "null"
     new 6df51ff  Add moduleDescriptor and moduleNameSource to JavadocModule
     new e86301e  Adjust file separator and adjust verify script

The 2 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.


Summary of changes:
 .../MJAVADOC-618_modular-war/verify.groovy         |  5 ++-
 .../maven/plugins/javadoc/AbstractJavadocMojo.java | 44 +++++++++++++---------
 .../maven/plugins/javadoc/JavadocModule.java       | 27 ++++++++++++-
 3 files changed, 55 insertions(+), 21 deletions(-)

[maven-javadoc-plugin] 02/02: Adjust file separator and adjust verify script

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

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

commit e86301ed09833aaac983cd18a27ba53a1f6be11e
Author: rfscholte <rf...@apache.org>
AuthorDate: Sun Aug 29 12:35:20 2021 +0200

    Adjust file separator and adjust verify script
---
 src/it/projects/MJAVADOC-618_modular-war/verify.groovy               | 5 +++--
 .../java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java   | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/it/projects/MJAVADOC-618_modular-war/verify.groovy b/src/it/projects/MJAVADOC-618_modular-war/verify.groovy
index 519f0e1..d665081 100644
--- a/src/it/projects/MJAVADOC-618_modular-war/verify.groovy
+++ b/src/it/projects/MJAVADOC-618_modular-war/verify.groovy
@@ -17,6 +17,7 @@
  * under the License.
  */
 
-assert new File( basedir, 'target/apidocs/argfile').readLines().size() == 4
+assert new File( basedir, 'target/apidocs/argfile').readLines().size() == 2
 assert new File( basedir, 'target/apidocs/com.mycompany.lib/com/mycompany/lib/Library.html').exists()
-assert new File( basedir, 'target/apidocs/com.mycompany.app/com/mycompany/app/Application.html').exists()
+// module descriptor of com.mycompany.app  has no exports, so nothing is documented
+assert !new File( basedir, 'target/apidocs/com.mycompany.app/com/mycompany/app/Application.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 8901360..c07e487 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -4729,11 +4729,11 @@ public abstract class AbstractJavadocMojo
                         continue;
                     }
 
-                    int lastIndexOfSeparator = currentFile.lastIndexOf( File.separatorChar );
+                    int lastIndexOfSeparator = currentFile.lastIndexOf( '/' );
                     if ( lastIndexOfSeparator != -1 )
                     {
                         String packagename =
-                            currentFile.substring( 0, lastIndexOfSeparator ).replace( File.separatorChar, '.' );
+                            currentFile.substring( 0, lastIndexOfSeparator ).replace( '/', '.' );
 
                         if ( exportAllPackages || exportedPackages.contains( packagename ) )
                         {

[maven-javadoc-plugin] 01/02: Add moduleDescriptor and moduleNameSource to JavadocModule

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

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

commit 6df51ff7d987a2878fcdea08e2e3a94120c0f7df
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Aug 28 19:46:22 2021 +0200

    Add moduleDescriptor and moduleNameSource to JavadocModule
---
 .../maven/plugins/javadoc/AbstractJavadocMojo.java | 40 +++++++++++++---------
 .../maven/plugins/javadoc/JavadocModule.java       | 27 ++++++++++++++-
 2 files changed, 50 insertions(+), 17 deletions(-)

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 8f5a6d1..8901360 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -2427,10 +2427,7 @@ public abstract class AbstractJavadocMojo
                 }
                 if ( !sourcePaths.isEmpty() )
                 {
-                    mappedSourcePaths.add( new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(),
-                                                                                            project.getArtifactId() ),
-                                                              getClassesFile( project ),
-                                                              sourcePaths ) );
+                    mappedSourcePaths.add( buildJavadocModule( project, sourcePaths ) );
                 }
             }
 
@@ -2471,11 +2468,7 @@ public abstract class AbstractJavadocMojo
                         
                         if ( !additionalSourcePaths.isEmpty() )
                         {
-                            mappedSourcePaths.add( new JavadocModule( 
-                                                          ArtifactUtils.versionlessKey( subProject.getGroupId(),
-                                                                                        subProject.getArtifactId() ),
-                                                          getClassesFile( subProject ),
-                                                          additionalSourcePaths ) );
+                            mappedSourcePaths.add( buildJavadocModule( subProject , additionalSourcePaths ) );
                         }
                     }
                 }
@@ -2509,6 +2502,26 @@ public abstract class AbstractJavadocMojo
 
         return mappedSourcePaths;
     }
+    
+    private JavadocModule buildJavadocModule( MavenProject project, Collection<Path> sourcePaths )
+    {
+        File classessFile = getClassesFile( project );
+        ResolvePathResult resolvePathResult = getResolvePathResult( classessFile );
+        if ( resolvePathResult == null )
+        {
+            return new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ),
+                                      classessFile, 
+                                      sourcePaths );
+        }
+        else
+        {
+            return new JavadocModule( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ),
+                                      classessFile, 
+                                      sourcePaths, 
+                                      resolvePathResult.getModuleDescriptor(),
+                                      resolvePathResult.getModuleNameSource() );
+        }
+    }
 
     /**
      * Recursively add the modules of the aggregatedProject to the set of aggregatedModules.
@@ -5161,7 +5174,6 @@ public abstract class AbstractJavadocMojo
 
         Map<String, JavaModuleDescriptor> allModuleDescriptors = new HashMap<>();
 
-        
         boolean supportModulePath = javadocRuntimeVersion.isAtLeast( "9" );
         if ( release != null ) 
         {
@@ -5176,11 +5188,7 @@ public abstract class AbstractJavadocMojo
         {
             for ( JavadocModule entry : allSourcePaths )
             {
-                File artifactFile = entry.getArtifactFile();
-                
-                ResolvePathResult resolvePathResult = getResolvePathResult( artifactFile );
-
-                if ( resolvePathResult == null || resolvePathResult.getModuleNameSource() == ModuleNameSource.FILENAME )
+                if ( entry.getModuleNameSource() == null || entry.getModuleNameSource() == ModuleNameSource.FILENAME )
                 {
                     Path moduleDescriptor = findMainDescriptor( entry.getSourcePaths() );
 
@@ -5199,7 +5207,7 @@ public abstract class AbstractJavadocMojo
                 }
                 else
                 {
-                    allModuleDescriptors.put( entry.getGa(), resolvePathResult.getModuleDescriptor() );
+                    allModuleDescriptors.put( entry.getGa(), entry.getModuleDescriptor() );
                 }
             }
         }
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
index 31c6cc6..1955e84 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocModule.java
@@ -23,6 +23,9 @@ import java.io.File;
 import java.nio.file.Path;
 import java.util.Collection;
 
+import org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor;
+import org.codehaus.plexus.languages.java.jpms.ModuleNameSource;
+
 /**
  * Represents a unit of Javadoc referring to the binary and java source paths  
  * 
@@ -36,11 +39,23 @@ public class JavadocModule
     
     private final Collection<Path> sourcePaths;
 
+    private final JavaModuleDescriptor moduleDescriptor;
+
+    private final ModuleNameSource moduleNameSource;
+
     public JavadocModule( String ga, File artifactFile, Collection<Path> sourcePaths )
     {
+        this( ga, artifactFile, sourcePaths, null, null );
+    }
+    
+    public JavadocModule( String ga, File artifactFile, Collection<Path> sourcePaths,
+                          JavaModuleDescriptor moduleDescriptor, ModuleNameSource moduleNameSource )
+    {
         this.ga = ga;
         this.artifactFile = artifactFile;
         this.sourcePaths = sourcePaths;
+        this.moduleDescriptor = moduleDescriptor;
+        this.moduleNameSource = moduleNameSource;
     }
 
     public String getGa()
@@ -52,9 +67,19 @@ public class JavadocModule
     {
         return sourcePaths;
     }
-    
+
     public File getArtifactFile()
     {
         return artifactFile;
     }
+
+    public JavaModuleDescriptor getModuleDescriptor()
+    {
+        return moduleDescriptor;
+    }
+
+    public ModuleNameSource getModuleNameSource()
+    {
+        return moduleNameSource;
+    }
 }