You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2023/12/13 12:15:08 UTC

Re: [PR] [MJAVADOC-783] Taglet path fixes [maven-javadoc-plugin]

elharo commented on code in PR #255:
URL: https://github.com/apache/maven-javadoc-plugin/pull/255#discussion_r1425267623


##########
src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java:
##########
@@ -118,32 +119,54 @@ public class JavadocUtil {
                     + "environment variable using -Xms:<size> and -Xmx:<size>.";
 
     /**
-     * Method that removes the invalid directories in the specified directories. <b>Note</b>: All elements in
-     * <code>dirs</code> could be an absolute or relative against the project's base directory <code>String</code> path.
+     * Method that removes invalid classpath elements in the specified paths. <b>Note</b>: All elements in
+     * <code>paths</code> could be absolute or relative against the project's base directory <code>String</code> path.
+     * When pruning class paths, you can optionally include "*.jar" files in the result, otherwise only directories are
+     * permitted.
      *
      * @param project the current Maven project not null
-     * @param dirs the collection of <code>String</code> directories path that will be validated.
-     * @return a List of valid <code>String</code> directories absolute paths.
+     * @param paths the collection of <code>String</code> paths that will be validated
+     * @param includeJars whether to include JAR files in the result
+     * @return a list of valid <code>String</code> directories and optionally JAR files as absolute paths
      */
-    public static Collection<Path> pruneDirs(MavenProject project, Collection<String> dirs) {
+    public static Collection<Path> prunePaths(MavenProject project, Collection<String> paths, boolean includeJars) {
         final Path projectBasedir = project.getBasedir().toPath();
 
-        Set<Path> pruned = new LinkedHashSet<>(dirs.size());
-        for (String dir : dirs) {
-            if (dir == null) {
+        Set<Path> pruned = new LinkedHashSet<>(paths.size());
+        for (String path : paths) {
+            if (path == null) {
                 continue;
             }
 
-            Path directory = projectBasedir.resolve(dir);
-
-            if (Files.isDirectory(directory)) {
-                pruned.add(directory.toAbsolutePath());
+            Path resolvedPath = projectBasedir.resolve(path);
+
+            if (Files.isDirectory(resolvedPath)
+                    || includeJars
+                            && Files.isRegularFile(resolvedPath)
+                            && resolvedPath
+                                    .getFileName()
+                                    .toString()
+                                    .toLowerCase(Locale.ROOT)
+                                    .endsWith(".jar")) {
+                pruned.add(resolvedPath.toAbsolutePath());
             }
         }
 
         return pruned;
     }
 
+    /**
+     * Method that removes the invalid directories in the specified directories. <b>Note</b>: All elements in
+     * <code>dirs</code> could be absolute or relative against the project's base directory <code>String</code> path.
+     *
+     * @param project the current Maven project not null
+     * @param dirs the collection of <code>String</code> directories that will be validated

Review Comment:
   the collection of <code>String</code> directories --> the paths of the directories
   are these relative or absolute? 



##########
src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java:
##########
@@ -118,32 +119,54 @@ public class JavadocUtil {
                     + "environment variable using -Xms:<size> and -Xmx:<size>.";
 
     /**
-     * Method that removes the invalid directories in the specified directories. <b>Note</b>: All elements in
-     * <code>dirs</code> could be an absolute or relative against the project's base directory <code>String</code> path.
+     * Method that removes invalid classpath elements in the specified paths. <b>Note</b>: All elements in
+     * <code>paths</code> could be absolute or relative against the project's base directory <code>String</code> path.
+     * When pruning class paths, you can optionally include "*.jar" files in the result, otherwise only directories are
+     * permitted.
      *
      * @param project the current Maven project not null
-     * @param dirs the collection of <code>String</code> directories path that will be validated.
-     * @return a List of valid <code>String</code> directories absolute paths.
+     * @param paths the collection of <code>String</code> paths that will be validated
+     * @param includeJars whether to include JAR files in the result
+     * @return a list of valid <code>String</code> directories and optionally JAR files as absolute paths

Review Comment:
   what does valid mean here?



##########
src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java:
##########
@@ -118,32 +119,54 @@ public class JavadocUtil {
                     + "environment variable using -Xms:<size> and -Xmx:<size>.";
 
     /**
-     * Method that removes the invalid directories in the specified directories. <b>Note</b>: All elements in
-     * <code>dirs</code> could be an absolute or relative against the project's base directory <code>String</code> path.
+     * Method that removes invalid classpath elements in the specified paths. <b>Note</b>: All elements in
+     * <code>paths</code> could be absolute or relative against the project's base directory <code>String</code> path.
+     * When pruning class paths, you can optionally include "*.jar" files in the result, otherwise only directories are
+     * permitted.
      *
      * @param project the current Maven project not null
-     * @param dirs the collection of <code>String</code> directories path that will be validated.
-     * @return a List of valid <code>String</code> directories absolute paths.
+     * @param paths the collection of <code>String</code> paths that will be validated

Review Comment:
   the collection of <code>String</code> paths --> the paths
   Javadoc will insert the types



##########
src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java:
##########
@@ -118,32 +119,54 @@ public class JavadocUtil {
                     + "environment variable using -Xms:<size> and -Xmx:<size>.";
 
     /**
-     * Method that removes the invalid directories in the specified directories. <b>Note</b>: All elements in
-     * <code>dirs</code> could be an absolute or relative against the project's base directory <code>String</code> path.
+     * Method that removes invalid classpath elements in the specified paths. <b>Note</b>: All elements in

Review Comment:
   What does invalid mean in this context? Rewrite Javadoc to clarify



##########
src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java:
##########
@@ -118,32 +119,54 @@ public class JavadocUtil {
                     + "environment variable using -Xms:<size> and -Xmx:<size>.";
 
     /**
-     * Method that removes the invalid directories in the specified directories. <b>Note</b>: All elements in
-     * <code>dirs</code> could be an absolute or relative against the project's base directory <code>String</code> path.
+     * Method that removes invalid classpath elements in the specified paths. <b>Note</b>: All elements in
+     * <code>paths</code> could be absolute or relative against the project's base directory <code>String</code> path.
+     * When pruning class paths, you can optionally include "*.jar" files in the result, otherwise only directories are
+     * permitted.
      *
      * @param project the current Maven project not null
-     * @param dirs the collection of <code>String</code> directories path that will be validated.
-     * @return a List of valid <code>String</code> directories absolute paths.
+     * @param paths the collection of <code>String</code> paths that will be validated
+     * @param includeJars whether to include JAR files in the result
+     * @return a list of valid <code>String</code> directories and optionally JAR files as absolute paths
      */
-    public static Collection<Path> pruneDirs(MavenProject project, Collection<String> dirs) {
+    public static Collection<Path> prunePaths(MavenProject project, Collection<String> paths, boolean includeJars) {
         final Path projectBasedir = project.getBasedir().toPath();
 
-        Set<Path> pruned = new LinkedHashSet<>(dirs.size());
-        for (String dir : dirs) {
-            if (dir == null) {
+        Set<Path> pruned = new LinkedHashSet<>(paths.size());
+        for (String path : paths) {
+            if (path == null) {
                 continue;
             }
 
-            Path directory = projectBasedir.resolve(dir);
-
-            if (Files.isDirectory(directory)) {
-                pruned.add(directory.toAbsolutePath());
+            Path resolvedPath = projectBasedir.resolve(path);
+
+            if (Files.isDirectory(resolvedPath)
+                    || includeJars
+                            && Files.isRegularFile(resolvedPath)
+                            && resolvedPath
+                                    .getFileName()
+                                    .toString()
+                                    .toLowerCase(Locale.ROOT)
+                                    .endsWith(".jar")) {
+                pruned.add(resolvedPath.toAbsolutePath());
             }
         }
 
         return pruned;
     }
 
+    /**
+     * Method that removes the invalid directories in the specified directories. <b>Note</b>: All elements in
+     * <code>dirs</code> could be absolute or relative against the project's base directory <code>String</code> path.
+     *
+     * @param project the current Maven project not null
+     * @param dirs the collection of <code>String</code> directories that will be validated
+     * @return a list of valid <code>String</code> directories as absolute paths

Review Comment:
   what does valid mean here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org