Skip to content

Commit c4b6a27

Browse files
committed
[JXR-189] Dynamically calculate javadocLocation/testJavadocLocation
1 parent 4744d81 commit c4b6a27

14 files changed

+36
-32
lines changed

maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private void createXref(Locale locale, File outputDirectory, List<String> source
215215
jxr.setLocale(locale);
216216
jxr.setOutputEncoding(getOutputEncoding());
217217
jxr.setRevision("HEAD");
218-
jxr.setJavadocLinkDir(getJavadocLocation());
218+
jxr.setJavadocLinkDir(constructJavadocLocation());
219219
// Set include/exclude patterns on the jxr instance
220220
if (excludes != null && !excludes.isEmpty()) {
221221
jxr.setExcludes(excludes.toArray(new String[0]));
@@ -468,30 +468,30 @@ public boolean isExternalReport() {
468468
/**
469469
* @return a String that contains the location of the javadocs
470470
*/
471-
private Path getJavadocLocation() throws IOException {
471+
private Path constructJavadocLocation() throws IOException {
472472
Path location = null;
473473
if (linkJavadoc) {
474474
// We don't need to do the whole translation thing like normal, because JXR does it internally.
475475
// It probably shouldn't.
476-
if (getJavadocDir().exists()) {
476+
if (getJavadocLocation().exists()) {
477477
// XRef was already generated by manual execution of a lifecycle binding
478-
location = getJavadocDir().toPath().toAbsolutePath();
478+
location = getJavadocLocation().toPath().toAbsolutePath();
479479
} else {
480480
// Not yet generated - check if the report is on its way
481481

482482
// Special case: using the site:stage goal
483483
String stagingDirectory = System.getProperty("stagingDirectory");
484484

485485
if (stagingDirectory != null && !stagingDirectory.isEmpty()) {
486-
String javadocDestDir = getJavadocDir().getName();
486+
String javadocOutputDir = getJavadocLocation().getName();
487487
boolean javadocAggregate = JxrReportUtil.isJavadocAggregated(project);
488488
String structureProject = JxrReportUtil.getStructure(project, false);
489489

490490
if (isAggregate() && javadocAggregate) {
491-
location = Paths.get(stagingDirectory, structureProject, javadocDestDir);
491+
location = Paths.get(stagingDirectory, structureProject, javadocOutputDir);
492492
}
493493
if (!isAggregate() && javadocAggregate) {
494-
location = Paths.get(stagingDirectory, javadocDestDir);
494+
location = Paths.get(stagingDirectory, javadocOutputDir);
495495

496496
String hierarchy = project.getName();
497497

@@ -500,17 +500,17 @@ private Path getJavadocLocation() throws IOException {
500500
hierarchy = parent.getName();
501501
parent = parent.getParent();
502502
}
503-
location = Paths.get(stagingDirectory, hierarchy, javadocDestDir);
503+
location = Paths.get(stagingDirectory, hierarchy, javadocOutputDir);
504504
}
505505
if (isAggregate() && !javadocAggregate) {
506506
getLog().warn("The JXR plugin is configured to build an aggregated report at the root, "
507507
+ "not the Javadoc plugin.");
508508
}
509509
if (!isAggregate() && !javadocAggregate) {
510-
location = Paths.get(stagingDirectory, structureProject, javadocDestDir);
510+
location = Paths.get(stagingDirectory, structureProject, javadocOutputDir);
511511
}
512512
} else {
513-
location = getJavadocDir().toPath();
513+
location = getJavadocLocation().toPath();
514514
}
515515
}
516516

@@ -547,11 +547,11 @@ private Path getJavadocLocation() throws IOException {
547547
protected abstract List<String> getSourceRoots(MavenProject project);
548548

549549
/**
550-
* Abstract method that returns the directory of the javadoc files.
550+
* Abstract method that returns the location where (Test) Javadoc is generated for this project.
551551
*
552-
* @return a File for the directory of the javadocs
552+
* @return a File for the location of (test) javadoc
553553
*/
554-
protected abstract File getJavadocDir();
554+
protected abstract File getJavadocLocation();
555555

556556
/**
557557
* Is the current report aggregated?

maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ public class JxrReport extends AbstractJxrReport {
5454

5555
/**
5656
* Directory where Javadoc is generated for this project.
57+
* <br>
58+
* <strong>Default</strong>: {@link #getReportOutputDirectory()} + {@code /apidocs}
5759
*/
58-
@Parameter(defaultValue = "${project.reporting.outputDirectory}/apidocs")
59-
private File javadocDir;
60+
@Parameter
61+
private File javadocLocation;
6062

6163
@Override
6264
protected File getPluginReportOutputDirectory() {
@@ -120,7 +122,7 @@ public String getOutputName() {
120122
}
121123

122124
@Override
123-
protected File getJavadocDir() {
124-
return javadocDir;
125+
protected File getJavadocLocation() {
126+
return javadocLocation != null ? javadocLocation : new File(getReportOutputDirectory(), "apidocs");
125127
}
126128
}

maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ public class JxrTestReport extends AbstractJxrReport {
4747

4848
/**
4949
* Directory where Test Javadoc is generated for this project.
50+
* <br>
51+
* <strong>Default</strong>: {@link #getReportOutputDirectory()} + {@code /testapidocs}
5052
*/
51-
@Parameter(defaultValue = "${project.reporting.outputDirectory}/testapidocs")
52-
private File testJavadocDir;
53+
@Parameter
54+
private File testJavadocLocation;
5355

5456
@Override
5557
protected List<String> getSourceRoots() {
@@ -102,7 +104,7 @@ public String getOutputName() {
102104
}
103105

104106
@Override
105-
protected File getJavadocDir() {
106-
return testJavadocDir;
107+
protected File getJavadocLocation() {
108+
return testJavadocLocation != null ? testJavadocLocation : new File(getReportOutputDirectory(), "testapidocs");
107109
}
108110
}

maven-jxr-plugin/src/test/resources/unit/aggregate-test/aggregate-test-plugin-config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ under the License.
4141
<value>${basedir}/src/test/resources/unit/aggregate-test/submodule1</value>
4242
<value>${basedir}/src/test/resources/unit/aggregate-test/submodule2</value>
4343
</sourceDirs>
44-
<javadocDir>${basedir}/target/test/unit/aggregate-test/target/site/apidocs</javadocDir>
44+
<javadocLocation>${basedir}/target/test/unit/aggregate-test/target/site/apidocs</javadocLocation>
4545
<linkJavadoc>false</linkJavadoc>
4646
<bottom>Copyright 2006 Apache Foundation</bottom>
4747
<javadocVersion>1.4</javadocVersion>

maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-4.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ under the License.
3939
<sourceDirs>
4040
<value>${basedir}/src/test/resources/unit/default-configuration</value>
4141
</sourceDirs>
42-
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/4/apidocs</javadocDir>
42+
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/4/apidocs</javadocLocation>
4343
<linkJavadoc>true</linkJavadoc>
4444
<bottom>Copyright 2006 Apache Foundation</bottom>
4545
<javadocVersion>1.4</javadocVersion>

maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-6.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ under the License.
3939
<sourceDirs>
4040
<value>${basedir}/src/test/resources/unit/default-configuration</value>
4141
</sourceDirs>
42-
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/6/apidocs</javadocDir>
42+
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/6/apidocs</javadocLocation>
4343
<linkJavadoc>true</linkJavadoc>
4444
<bottom>Copyright 2006 Apache Foundation</bottom>
4545
<javadocVersion>1.6</javadocVersion>

maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-7.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ under the License.
3939
<sourceDirs>
4040
<value>${basedir}/src/test/resources/unit/default-configuration</value>
4141
</sourceDirs>
42-
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/7/apidocs</javadocDir>
42+
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/7/apidocs</javadocLocation>
4343
<linkJavadoc>true</linkJavadoc>
4444
<bottom>Copyright 2006 Apache Foundation</bottom>
4545
<javadocVersion>1.7</javadocVersion>

maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config-8.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ under the License.
3939
<sourceDirs>
4040
<value>${basedir}/src/test/resources/unit/default-configuration</value>
4141
</sourceDirs>
42-
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/8/apidocs</javadocDir>
42+
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/8/apidocs</javadocLocation>
4343
<linkJavadoc>true</linkJavadoc>
4444
<bottom>Copyright 2006 Apache Foundation</bottom>
4545
<javadocVersion>1.8</javadocVersion>

maven-jxr-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ under the License.
3939
<sourceDirs>
4040
<value>${basedir}/src/test/resources/unit/default-configuration</value>
4141
</sourceDirs>
42-
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/apidocs</javadocDir>
42+
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/apidocs</javadocLocation>
4343
<linkJavadoc>true</linkJavadoc>
4444
<bottom>Copyright 2006 Apache Foundation</bottom>
4545
<templateDir>templates</templateDir>

maven-jxr-plugin/src/test/resources/unit/default-configuration/exception-test-plugin-config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ under the License.
4040
<sourceDirs>
4141
<value>${basedir}/src/test/resources/unit/default-configuration</value>
4242
</sourceDirs>
43-
<javadocDir>${basedir}/target/test/unit/default-configuration/target/site/apidocs</javadocDir>
43+
<javadocLocation>${basedir}/target/test/unit/default-configuration/target/site/apidocs</javadocLocation>
4444
<linkJavadoc>true</linkJavadoc>
4545
<bottom>Copyright 2006 Apache Foundation</bottom>
4646
<templateDir>temp</templateDir>

maven-jxr-plugin/src/test/resources/unit/exclude-configuration/exclude-configuration-plugin-config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ under the License.
4040
<sourceDirs>
4141
<value>${basedir}/src/test/resources/unit/exclude-configuration</value>
4242
</sourceDirs>
43-
<javadocDir>${basedir}/target/test/unit/exclude-configuration/target/site/apidocs</javadocDir>
43+
<javadocLocation>${basedir}/target/test/unit/exclude-configuration/target/site/apidocs</javadocLocation>
4444
<linkJavadoc>true</linkJavadoc>
4545
<bottom>Copyright 2006 Apache Foundation</bottom>
4646
<javadocVersion>1.4</javadocVersion>

maven-jxr-plugin/src/test/resources/unit/include-configuration/include-configuration-plugin-config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ under the License.
4040
<sourceDirs>
4141
<value>${basedir}/src/test/resources/unit/include-configuration</value>
4242
</sourceDirs>
43-
<javadocDir>${basedir}/target/test/unit/include-configuration/target/site/apidocs</javadocDir>
43+
<javadocLocation>${basedir}/target/test/unit/include-configuration/target/site/apidocs</javadocLocation>
4444
<linkJavadoc>true</linkJavadoc>
4545
<bottom>Copyright 2006 Apache Foundation</bottom>
4646
<javadocVersion>1.4</javadocVersion>

maven-jxr-plugin/src/test/resources/unit/nojavadocdir-test/nojavadocdir-test-plugin-config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ under the License.
4040
<sourceDirs>
4141
<value>${basedir}/src/test/resources/unit/nojavadocdir-test</value>
4242
</sourceDirs>
43-
<javadocDir>${basedir}/target/test/unit/nojavadocdir-test/target/site/apidocs</javadocDir>
43+
<javadocLocation>${basedir}/target/test/unit/nojavadocLocation-test/target/site/apidocs</javadocLocation>
4444
<linkJavadoc>true</linkJavadoc>
4545
<bottom>Copyright 2006 Apache Foundation</bottom>
4646
<javadocVersion>1.4</javadocVersion>

maven-jxr-plugin/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ under the License.
4040
<sourceDirs>
4141
<value>${basedir}/src/test/resources/unit/nojavadoclink-configuration</value>
4242
</sourceDirs>
43-
<javadocDir>${basedir}/target/test/unit/nojavadoclink-configuration/target/site/apidocs</javadocDir>
43+
<javadocLocation>${basedir}/target/test/unit/nojavadoclink-configuration/target/site/apidocs</javadocLocation>
4444
<linkJavadoc>false</linkJavadoc>
4545
<bottom>Copyright 2006 Apache Foundation</bottom>
4646
<javadocVersion>1.4</javadocVersion>

0 commit comments

Comments
 (0)