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

michaelo pushed a commit to branch doxia-2.0.0
in repository https://gitbox.apache.org/repos/asf/maven-jxr.git

commit 9ad89e0d88eddb25482a205a295a334508d5da79
Author: Michael Osipov <micha...@apache.org>
AuthorDate: Sun Nov 12 23:40:40 2023 +0100

    Dynamically calculate javadocLocation/testJavadocLocation
---
 .../apache/maven/plugin/jxr/AbstractJxrReport.java | 26 +++++++++++-----------
 .../org/apache/maven/plugin/jxr/JxrReport.java     | 10 +++++----
 .../org/apache/maven/plugin/jxr/JxrTestReport.java | 10 +++++----
 .../aggregate-test-plugin-config.xml               |  2 +-
 .../default-configuration-plugin-config-4.xml      |  2 +-
 .../default-configuration-plugin-config-6.xml      |  2 +-
 .../default-configuration-plugin-config-7.xml      |  2 +-
 .../default-configuration-plugin-config-8.xml      |  2 +-
 .../default-configuration-plugin-config.xml        |  2 +-
 .../exception-test-plugin-config.xml               |  2 +-
 .../exclude-configuration-plugin-config.xml        |  2 +-
 .../include-configuration-plugin-config.xml        |  2 +-
 .../nojavadocdir-test-plugin-config.xml            |  2 +-
 .../nojavadoclink-configuration-plugin-config.xml  |  2 +-
 14 files changed, 36 insertions(+), 32 deletions(-)

diff --git 
a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java
 
b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java
index 108c41c..bff8e6b 100644
--- 
a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java
+++ 
b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java
@@ -215,7 +215,7 @@ public abstract class AbstractJxrReport extends 
AbstractMavenReport {
         jxr.setLocale(locale);
         jxr.setOutputEncoding(getOutputEncoding());
         jxr.setRevision("HEAD");
-        jxr.setJavadocLinkDir(getJavadocLocation());
+        jxr.setJavadocLinkDir(constructJavadocLocation());
         // Set include/exclude patterns on the jxr instance
         if (excludes != null && !excludes.isEmpty()) {
             jxr.setExcludes(excludes.toArray(new String[0]));
@@ -468,14 +468,14 @@ public abstract class AbstractJxrReport extends 
AbstractMavenReport {
     /**
      * @return a String that contains the location of the javadocs
      */
-    private Path getJavadocLocation() throws IOException {
+    private Path constructJavadocLocation() throws IOException {
         Path location = null;
         if (linkJavadoc) {
             // We don't need to do the whole translation thing like normal, 
because JXR does it internally.
             // It probably shouldn't.
-            if (getJavadocDir().exists()) {
+            if (getJavadocLocation().exists()) {
                 // XRef was already generated by manual execution of a 
lifecycle binding
-                location = getJavadocDir().toPath().toAbsolutePath();
+                location = getJavadocLocation().toPath().toAbsolutePath();
             } else {
                 // Not yet generated - check if the report is on its way
 
@@ -483,15 +483,15 @@ public abstract class AbstractJxrReport extends 
AbstractMavenReport {
                 String stagingDirectory = 
System.getProperty("stagingDirectory");
 
                 if (stagingDirectory != null && !stagingDirectory.isEmpty()) {
-                    String javadocDestDir = getJavadocDir().getName();
+                    String javadocOutputDir = getJavadocLocation().getName();
                     boolean javadocAggregate = 
JxrReportUtil.isJavadocAggregated(project);
                     String structureProject = 
JxrReportUtil.getStructure(project, false);
 
                     if (isAggregate() && javadocAggregate) {
-                        location = Paths.get(stagingDirectory, 
structureProject, javadocDestDir);
+                        location = Paths.get(stagingDirectory, 
structureProject, javadocOutputDir);
                     }
                     if (!isAggregate() && javadocAggregate) {
-                        location = Paths.get(stagingDirectory, javadocDestDir);
+                        location = Paths.get(stagingDirectory, 
javadocOutputDir);
 
                         String hierarchy = project.getName();
 
@@ -500,17 +500,17 @@ public abstract class AbstractJxrReport extends 
AbstractMavenReport {
                             hierarchy = parent.getName();
                             parent = parent.getParent();
                         }
-                        location = Paths.get(stagingDirectory, hierarchy, 
javadocDestDir);
+                        location = Paths.get(stagingDirectory, hierarchy, 
javadocOutputDir);
                     }
                     if (isAggregate() && !javadocAggregate) {
                         getLog().warn("The JXR plugin is configured to build 
an aggregated report at the root, "
                                 + "not the Javadoc plugin.");
                     }
                     if (!isAggregate() && !javadocAggregate) {
-                        location = Paths.get(stagingDirectory, 
structureProject, javadocDestDir);
+                        location = Paths.get(stagingDirectory, 
structureProject, javadocOutputDir);
                     }
                 } else {
-                    location = getJavadocDir().toPath();
+                    location = getJavadocLocation().toPath();
                 }
             }
 
@@ -547,11 +547,11 @@ public abstract class AbstractJxrReport extends 
AbstractMavenReport {
     protected abstract List<String> getSourceRoots(MavenProject project);
 
     /**
-     * Abstract method that returns the directory of the javadoc files.
+     * Abstract method that returns the location where (Test) Javadoc is 
generated for this project.
      *
-     * @return a File for the directory of the javadocs
+     * @return a File for the location of (test) javadoc
      */
-    protected abstract File getJavadocDir();
+    protected abstract File getJavadocLocation();
 
     /**
      * Is the current report aggregated?
diff --git 
a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java 
b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java
index def85f4..8f2f6a4 100644
--- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java
+++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java
@@ -54,9 +54,11 @@ public class JxrReport extends AbstractJxrReport {
 
     /**
      * Directory where Javadoc is generated for this project.
+     * <br>
+     * <strong>Default</strong>: {@link #getReportOutputDirectory()} + {@code 
/apidocs}
      */
-    @Parameter(defaultValue = "${project.reporting.outputDirectory}/apidocs")
-    private File javadocDir;
+    @Parameter
+    private File javadocLocation;
 
     @Override
     protected File getPluginReportOutputDirectory() {
@@ -120,7 +122,7 @@ public class JxrReport extends AbstractJxrReport {
     }
 
     @Override
-    protected File getJavadocDir() {
-        return javadocDir;
+    protected File getJavadocLocation() {
+        return javadocLocation != null ? javadocLocation : new 
File(getReportOutputDirectory(), "apidocs");
     }
 }
diff --git 
a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java 
b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java
index a4a1709..a3c5e62 100644
--- 
a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java
+++ 
b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java
@@ -47,9 +47,11 @@ public class JxrTestReport extends AbstractJxrReport {
 
     /**
      * Directory where Test Javadoc is generated for this project.
+     * <br>
+     * <strong>Default</strong>: {@link #getReportOutputDirectory()} + {@code 
/testapidocs}
      */
-    @Parameter(defaultValue = 
"${project.reporting.outputDirectory}/testapidocs")
-    private File testJavadocDir;
+    @Parameter
+    private File testJavadocLocation;
 
     @Override
     protected List<String> getSourceRoots() {
@@ -102,7 +104,7 @@ public class JxrTestReport extends AbstractJxrReport {
     }
 
     @Override
-    protected File getJavadocDir() {
-        return testJavadocDir;
+    protected File getJavadocLocation() {
+        return testJavadocLocation != null ? testJavadocLocation : new 
File(getReportOutputDirectory(), "testapidocs");
     }
 }
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/aggregate-test/aggregate-test-plugin-config.xml
 
b/maven-jxr-plugin/src/test/resources/unit/aggregate-test/aggregate-test-plugin-config.xml
index 73c0ab4..5343001 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/aggregate-test/aggregate-test-plugin-config.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/aggregate-test/aggregate-test-plugin-config.xml
@@ -41,7 +41,7 @@ under the License.
             
<value>${basedir}/src/test/resources/unit/aggregate-test/submodule1</value>
             
<value>${basedir}/src/test/resources/unit/aggregate-test/submodule2</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/aggregate-test/target/site/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/aggregate-test/target/site/apidocs</javadocLocation>
           <linkJavadoc>false</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <javadocVersion>1.4</javadocVersion>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-4.xml
 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-4.xml
index 410f864..e6e2619 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-4.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-4.xml
@@ -39,7 +39,7 @@ under the License.
           <sourceDirs>
             
<value>${basedir}/src/test/resources/unit/default-configuration</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/4/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/4/apidocs</javadocLocation>
           <linkJavadoc>true</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <javadocVersion>1.4</javadocVersion>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-6.xml
 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-6.xml
index 5d0184d..3067637 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-6.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-6.xml
@@ -39,7 +39,7 @@ under the License.
           <sourceDirs>
             
<value>${basedir}/src/test/resources/unit/default-configuration</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/6/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/6/apidocs</javadocLocation>
           <linkJavadoc>true</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <javadocVersion>1.6</javadocVersion>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-7.xml
 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-7.xml
index 8620129..a5b58bf 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-7.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-7.xml
@@ -39,7 +39,7 @@ under the License.
           <sourceDirs>
             
<value>${basedir}/src/test/resources/unit/default-configuration</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/7/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/7/apidocs</javadocLocation>
           <linkJavadoc>true</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <javadocVersion>1.7</javadocVersion>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-8.xml
 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-8.xml
index 486776a..df1fff7 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-8.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-8.xml
@@ -39,7 +39,7 @@ under the License.
           <sourceDirs>
             
<value>${basedir}/src/test/resources/unit/default-configuration</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/8/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/8/apidocs</javadocLocation>
           <linkJavadoc>true</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <javadocVersion>1.8</javadocVersion>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
index a457dce..e17feb1 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml
@@ -39,7 +39,7 @@ under the License.
           <sourceDirs>
             
<value>${basedir}/src/test/resources/unit/default-configuration</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/apidocs</javadocLocation>
           <linkJavadoc>true</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <templateDir>templates</templateDir>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/exception-test-plugin-config.xml
 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/exception-test-plugin-config.xml
index 06039de..b495874 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/default-configuration/exception-test-plugin-config.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/default-configuration/exception-test-plugin-config.xml
@@ -40,7 +40,7 @@ under the License.
           <sourceDirs>
             
<value>${basedir}/src/test/resources/unit/default-configuration</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/apidocs</javadocLocation>
           <linkJavadoc>true</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <templateDir>temp</templateDir>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/exclude-configuration/exclude-configuration-plugin-config.xml
 
b/maven-jxr-plugin/src/test/resources/unit/exclude-configuration/exclude-configuration-plugin-config.xml
index ff9bef7..33e057b 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/exclude-configuration/exclude-configuration-plugin-config.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/exclude-configuration/exclude-configuration-plugin-config.xml
@@ -40,7 +40,7 @@ under the License.
           <sourceDirs>
             
<value>${basedir}/src/test/resources/unit/exclude-configuration</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/exclude-configuration/target/site/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/exclude-configuration/target/site/apidocs</javadocLocation>
           <linkJavadoc>true</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <javadocVersion>1.4</javadocVersion>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/include-configuration/include-configuration-plugin-config.xml
 
b/maven-jxr-plugin/src/test/resources/unit/include-configuration/include-configuration-plugin-config.xml
index 2cda959..84128a0 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/include-configuration/include-configuration-plugin-config.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/include-configuration/include-configuration-plugin-config.xml
@@ -40,7 +40,7 @@ under the License.
           <sourceDirs>
             
<value>${basedir}/src/test/resources/unit/include-configuration</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/include-configuration/target/site/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/include-configuration/target/site/apidocs</javadocLocation>
           <linkJavadoc>true</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <javadocVersion>1.4</javadocVersion>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/nojavadocdir-test/nojavadocdir-test-plugin-config.xml
 
b/maven-jxr-plugin/src/test/resources/unit/nojavadocdir-test/nojavadocdir-test-plugin-config.xml
index fed568a..255b59e 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/nojavadocdir-test/nojavadocdir-test-plugin-config.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/nojavadocdir-test/nojavadocdir-test-plugin-config.xml
@@ -40,7 +40,7 @@ under the License.
           <sourceDirs>
             <value>${basedir}/src/test/resources/unit/nojavadocdir-test</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/nojavadocdir-test/target/site/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/nojavadocLocation-test/target/site/apidocs</javadocLocation>
           <linkJavadoc>true</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <javadocVersion>1.4</javadocVersion>
diff --git 
a/maven-jxr-plugin/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml
 
b/maven-jxr-plugin/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml
index b66627d..4dc92a0 100644
--- 
a/maven-jxr-plugin/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml
+++ 
b/maven-jxr-plugin/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml
@@ -40,7 +40,7 @@ under the License.
           <sourceDirs>
             
<value>${basedir}/src/test/resources/unit/nojavadoclink-configuration</value>
           </sourceDirs>
-          
<javadocDir>${basedir}/target/test/unit/nojavadoclink-configuration/target/site/apidocs</javadocDir>
+          
<javadocLocation>${basedir}/target/test/unit/nojavadoclink-configuration/target/site/apidocs</javadocLocation>
           <linkJavadoc>false</linkJavadoc>
           <bottom>Copyright 2006 Apache Foundation</bottom>
           <javadocVersion>1.4</javadocVersion>

Reply via email to