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

elharo 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 1085259a Use Java 7 relativization instead of our hand-rolled code 
(#381)
1085259a is described below

commit 1085259aa7732bdc0145fb0cf64bb19be554ebfa
Author: Elliotte Rusty Harold <elh...@users.noreply.github.com>
AuthorDate: Mon Jun 2 19:09:09 2025 +0000

    Use Java 7 relativization instead of our hand-rolled code (#381)
    
    * Use Java 7 relativization instead of our hand-rolled code
---
 .../apache/maven/plugins/javadoc/AbstractJavadocMojo.java | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 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 d076514b..93615668 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -145,7 +145,7 @@ import static 
org.apache.maven.plugins.javadoc.JavadocUtil.toList;
 import static org.apache.maven.plugins.javadoc.JavadocUtil.toRelative;
 
 /**
- * Base class with majority of Javadoc functionalities.
+ * Base class with the majority of Javadoc functionality.
  *
  * @author <a href="mailto:br...@apache.org";>Brett Porter</a>
  * @author <a href="mailto:vincent.sive...@gmail.com";>Vincent Siveton</a>
@@ -2177,12 +2177,15 @@ public abstract class AbstractJavadocMojo extends 
AbstractMojo {
                         }
 
                         if (getJavadocDirectory() != null) {
-                            String javadocDirRelative = PathUtils.toRelative(
-                                    project.getBasedir(), 
getJavadocDirectory().getAbsolutePath());
-                            File javadocDir = new 
File(subProject.getBasedir(), javadocDirRelative);
-                            if (javadocDir.exists() && 
javadocDir.isDirectory()) {
+                            Path base = project.getBasedir().toPath();
+                            Path relative = base.relativize(
+                                    
getJavadocDirectory().toPath().toAbsolutePath());
+                            Path javadocDir = 
subProject.getBasedir().toPath().resolve(relative);
+                            if (Files.isDirectory(javadocDir)) {
                                 Collection<Path> l = JavadocUtil.pruneDirs(
-                                        subProject, 
Collections.singletonList(javadocDir.getAbsolutePath()));
+                                        subProject,
+                                        Collections.singletonList(
+                                                
javadocDir.toAbsolutePath().toString()));
                                 additionalSourcePaths.addAll(l);
                             }
                         }

Reply via email to