Skip to content

Commit 4744d81

Browse files
committed
[JXR-188] Upgrade to Doxia 2.0.0 Milestone Stack
This closes #64
1 parent 2cd6a44 commit 4744d81

38 files changed

+297
-242
lines changed

maven-jxr-plugin/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ under the License.
8989
<dependency>
9090
<groupId>org.apache.maven.reporting</groupId>
9191
<artifactId>maven-reporting-api</artifactId>
92-
<version>3.1.1</version>
92+
<version>4.0.0-M12</version>
9393
</dependency>
9494
<dependency>
9595
<groupId>org.apache.maven.reporting</groupId>
9696
<artifactId>maven-reporting-impl</artifactId>
97-
<version>3.2.0</version>
97+
<version>4.0.0-M15</version>
9898
</dependency>
9999

100100
<!-- shared utils -->

maven-jxr-plugin/src/it/JXR-100_parameterlink/verify.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
assert new File( basedir, 'target/site/xref/com/mycompany/app/Foo.html' ).exists()
19+
File file = new File( basedir, 'target/reports/xref/com/mycompany/app/Foo.html' );
2020

21-
assert 4 == new File( basedir, '/target/site/xref/com/mycompany/app/Foo.html' ).text.count( '<a name="App" href="../../../com/mycompany/app/App.html#App">App</a>' )
21+
assert file.exists()
22+
23+
assert 4 == file.text.count( '<a name="App" href="../../../com/mycompany/app/App.html#App">App</a>' )

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

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.maven.jxr.pacman.FileManager;
3838
import org.apache.maven.jxr.pacman.PackageManager;
3939
import org.apache.maven.model.ReportPlugin;
40+
import org.apache.maven.plugin.MojoExecution;
4041
import org.apache.maven.plugins.annotations.Parameter;
4142
import org.apache.maven.project.MavenProject;
4243
import org.apache.maven.reporting.AbstractMavenReport;
@@ -73,10 +74,7 @@ public abstract class AbstractJxrReport extends AbstractMavenReport {
7374
/**
7475
* String used at the bottom of the Xref HTML files.
7576
*/
76-
@Parameter(
77-
property = "bottom",
78-
defaultValue =
79-
"Copyright &#169; {inceptionYear}&#x2013;{currentYear} {organizationName}. All rights reserved.")
77+
@Parameter(property = "bottom", defaultValue = "\u00A9 {inceptionYear}\u2013{currentYear} {organizationName}")
8078
private String bottom;
8179

8280
// CHECKSTYLE_ON: LineLength
@@ -111,12 +109,6 @@ public abstract class AbstractJxrReport extends AbstractMavenReport {
111109
@Parameter
112110
private ArrayList<String> includes;
113111

114-
/**
115-
* The projects in the reactor for aggregation report.
116-
*/
117-
@Parameter(defaultValue = "${reactorProjects}", readonly = true)
118-
protected List<MavenProject> reactorProjects;
119-
120112
/**
121113
* Whether to skip this execution.
122114
*
@@ -202,23 +194,23 @@ && hasSources(currentFile)) {
202194
}
203195

204196
/**
205-
* Creates the Xref for the Java files found in the given source directory and puts them in the given destination
197+
* Creates the Xref for the Java files found in the given source directory and puts them in the given output
206198
* directory.
207199
*
208200
* @param locale The user locale to use for the Xref generation
209-
* @param destinationDirectory The output directory
201+
* @param outputDirectory The output directory
210202
* @param sourceDirs The source directories
211203
* @throws java.io.IOException
212204
* @throws org.apache.maven.jxr.JxrException
213205
*/
214-
private void createXref(Locale locale, String destinationDirectory, List<String> sourceDirs)
206+
private void createXref(Locale locale, File outputDirectory, List<String> sourceDirs)
215207
throws IOException, JxrException {
216208
FileManager fileManager = new FileManager();
217209
PackageManager packageManager = new PackageManager(fileManager);
218210
JavaCodeTransform codeTransform = new JavaCodeTransform(packageManager, fileManager);
219211

220212
JXR jxr = new JXR(packageManager, codeTransform);
221-
jxr.setDest(Paths.get(destinationDirectory));
213+
jxr.setDest(outputDirectory.toPath());
222214
jxr.setInputEncoding(getInputEncoding());
223215
jxr.setLocale(locale);
224216
jxr.setOutputEncoding(getOutputEncoding());
@@ -242,11 +234,11 @@ private void createXref(Locale locale, String destinationDirectory, List<String>
242234
}
243235

244236
// and finally copy the stylesheet
245-
copyRequiredResources(destinationDirectory);
237+
copyRequiredResources(outputDirectory);
246238
}
247239

248240
/**
249-
* Returns the bottom text to be displayed at the lower part of the generated JXR reports.
241+
* Returns the bottom text to be displayed at the lower part of the generated JXR report.
250242
*/
251243
private String getBottomText() {
252244
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
@@ -258,12 +250,12 @@ private String getBottomText() {
258250

259251
if (inceptionYear != null) {
260252
if (inceptionYear.equals(year)) {
261-
theBottom = StringUtils.replace(theBottom, "{inceptionYear}&#x2013;", "");
253+
theBottom = StringUtils.replace(theBottom, "{inceptionYear}\u2013", "");
262254
} else {
263255
theBottom = StringUtils.replace(theBottom, "{inceptionYear}", inceptionYear);
264256
}
265257
} else {
266-
theBottom = StringUtils.replace(theBottom, "{inceptionYear}&#x2013;", "");
258+
theBottom = StringUtils.replace(theBottom, "{inceptionYear}\u2013", "");
267259
}
268260

269261
if (project.getOrganization() == null) {
@@ -293,28 +285,28 @@ private String getBottomText() {
293285
}
294286

295287
/**
296-
* Copy some required resources (like the stylesheet) to the given directory
288+
* Copy some required resources (like the stylesheet) to the given target directory
297289
*
298-
* @param dir the directory to copy the resources to
290+
* @param targetDirectory the directory to copy the resources to
299291
*/
300-
private void copyRequiredResources(String dir) {
292+
private void copyRequiredResources(File targetDirectory) {
301293
if (stylesheet != null && !stylesheet.isEmpty()) {
302294
File stylesheetFile = new File(stylesheet);
303-
File destStylesheetFile = new File(dir, "stylesheet.css");
295+
File targetStylesheetFile = new File(targetDirectory, "stylesheet.css");
304296

305297
try {
306298
if (stylesheetFile.isAbsolute()) {
307-
FileUtils.copyFile(stylesheetFile, destStylesheetFile);
299+
FileUtils.copyFile(stylesheetFile, targetStylesheetFile);
308300
} else {
309301
URL stylesheetUrl = this.getClass().getClassLoader().getResource(stylesheet);
310-
FileUtils.copyURLToFile(stylesheetUrl, destStylesheetFile);
302+
FileUtils.copyURLToFile(stylesheetUrl, targetStylesheetFile);
311303
}
312304
} catch (IOException e) {
313305
getLog().warn("An error occured while copying the stylesheet to the target directory", e);
314306
}
315307
} else {
316308
if (javadocTemplatesVersion.isAtLeast("1.8")) {
317-
copyResources(dir, "jdk8/", "stylesheet.css");
309+
copyResources(targetDirectory, "jdk8/", "stylesheet.css");
318310
} else if (javadocTemplatesVersion.isAtLeast("1.7")) {
319311
String[] jdk7Resources = {
320312
"stylesheet.css",
@@ -323,31 +315,31 @@ private void copyRequiredResources(String dir) {
323315
"resources/titlebar.gif",
324316
"resources/titlebar_end.gif"
325317
};
326-
copyResources(dir, "jdk7/", jdk7Resources);
318+
copyResources(targetDirectory, "jdk7/", jdk7Resources);
327319
} else if (javadocTemplatesVersion.isAtLeast("1.6")) {
328-
copyResources(dir, "jdk6/", "stylesheet.css");
320+
copyResources(targetDirectory, "jdk6/", "stylesheet.css");
329321
} else if (javadocTemplatesVersion.isAtLeast("1.4")) {
330-
copyResources(dir, "jdk4/", "stylesheet.css");
322+
copyResources(targetDirectory, "jdk4/", "stylesheet.css");
331323
} else {
332324
// Fallback to the original stylesheet
333-
copyResources(dir, "", "stylesheet.css");
325+
copyResources(targetDirectory, "", "stylesheet.css");
334326
}
335327
}
336328
}
337329

338330
/**
339331
* Copy styles and related resources to the given directory
340332
*
341-
* @param dir the directory to copy the resources to
333+
* @param targetDirectory the target directory to copy the resources to
342334
* @param sourceDirectory resources subdirectory to copy from
343335
* @param files names of files to copy
344336
*/
345-
private void copyResources(String dir, String sourceDirectory, String... files) {
337+
private void copyResources(File targetDirectory, String sourceDirectory, String... files) {
346338
try {
347339
for (String file : files) {
348340
URL resourceUrl = this.getClass().getClassLoader().getResource(sourceDirectory + file);
349-
File destResourceFile = new File(dir, file);
350-
FileUtils.copyURLToFile(resourceUrl, destResourceFile);
341+
File targetResourceFile = new File(targetDirectory, file);
342+
FileUtils.copyURLToFile(resourceUrl, targetResourceFile);
351343
}
352344
} catch (IOException e) {
353345
getLog().warn("An error occured while copying the resource to the target directory", e);
@@ -359,14 +351,18 @@ protected MavenProject getProject() {
359351
return project;
360352
}
361353

362-
/**
363-
* Returns the Maven session.
364-
* @return Maven session
365-
*/
366354
protected MavenSession getSession() {
367355
return session;
368356
}
369357

358+
protected List<MavenProject> getReactorProjects() {
359+
return reactorProjects;
360+
}
361+
362+
protected MojoExecution getMojoExecution() {
363+
return mojoExecution;
364+
}
365+
370366
/**
371367
* Returns the correct resource bundle according to the locale.
372368
*
@@ -386,7 +382,7 @@ protected void executeReport(Locale locale) throws MavenReportException {
386382
setJavadocTemplatesVersion();
387383

388384
try {
389-
createXref(locale, getDestinationDirectory(), constructSourceDirs());
385+
createXref(locale, getPluginReportOutputDirectory(), constructSourceDirs());
390386
} catch (JxrException | IOException e) {
391387
throw new MavenReportException("Error while generating the HTML source code of the project.", e);
392388
}
@@ -450,7 +446,6 @@ protected List<String> constructSourceDirs() {
450446
@Override
451447
public boolean canGenerateReport() {
452448
if (skip) {
453-
getLog().info("Skipping JXR.");
454449
return false;
455450
}
456451

@@ -528,11 +523,12 @@ private Path getJavadocLocation() throws IOException {
528523
}
529524

530525
/**
531-
* Abstract method that returns the target directory where the generated JXR reports will be put.
526+
* Abstract method that returns the plugin report output directory where the generated JXR report will be put
527+
* beneath {@link #getReportOutputDirectory()}.
532528
*
533-
* @return a String that contains the target directory name
529+
* @return a File for the plugin's report output directory
534530
*/
535-
protected abstract String getDestinationDirectory();
531+
protected abstract File getPluginReportOutputDirectory();
536532

537533
/**
538534
* Abstract method that returns the specified source directories that will be included in the JXR report generation.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.apache.maven.plugins.annotations.Mojo;
2424

2525
/**
26-
* Creates an html-based, cross referenced version of Java source code
26+
* Creates an HTML-based, cross referenced version of Java source code
2727
* for a project without forking. Note that this goal does require generation of sources before
2828
* site generation, e.g. by invoking {@code }mvn clean deploy site}.
2929
*

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.apache.maven.project.MavenProject;
3232

3333
/**
34-
* Creates an html-based, cross referenced version of Java source code
34+
* Creates an HTML-based, cross referenced version of Java source code
3535
* for a project.
3636
*
3737
* @author <a href="mailto:[email protected]">Fabrice Bellingard</a>
@@ -52,21 +52,15 @@ public class JxrReport extends AbstractJxrReport {
5252
@Parameter
5353
private String sourcePath;
5454

55-
/**
56-
* Directory where the Xref files will be copied to.
57-
*/
58-
@Parameter(defaultValue = "${project.reporting.outputDirectory}/xref")
59-
private String destDir;
60-
6155
/**
6256
* Directory where Javadoc is generated for this project.
6357
*/
6458
@Parameter(defaultValue = "${project.reporting.outputDirectory}/apidocs")
6559
private File javadocDir;
6660

6761
@Override
68-
protected String getDestinationDirectory() {
69-
return destDir;
62+
protected File getPluginReportOutputDirectory() {
63+
return new File(getReportOutputDirectory(), "xref");
7064
}
7165

7266
@Override
@@ -80,12 +74,12 @@ protected List<String> getSourceRoots() {
8074

8175
List<String> l = new ArrayList<>();
8276

83-
if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.US))) {
77+
if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
8478
l.addAll(sourceDirs);
8579
}
8680

8781
if (getProject().getExecutionProject() != null) {
88-
if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.US))) {
82+
if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
8983
l.addAll(getProject().getExecutionProject().getCompileSourceRoots());
9084
}
9185
}
@@ -97,12 +91,12 @@ protected List<String> getSourceRoots() {
9791
protected List<String> getSourceRoots(MavenProject project) {
9892
List<String> l = new ArrayList<>();
9993

100-
if (!"pom".equals(project.getPackaging().toLowerCase(Locale.US))) {
94+
if (!"pom".equals(project.getPackaging().toLowerCase(Locale.ENGLISH))) {
10195
l.addAll(project.getCompileSourceRoots());
10296
}
10397

10498
if (project.getExecutionProject() != null) {
105-
if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.US))) {
99+
if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
106100
l.addAll(project.getExecutionProject().getCompileSourceRoots());
107101
}
108102
}
@@ -129,14 +123,4 @@ public String getOutputName() {
129123
protected File getJavadocDir() {
130124
return javadocDir;
131125
}
132-
133-
@Override
134-
public void setReportOutputDirectory(File reportOutputDirectory) {
135-
if ((reportOutputDirectory != null)
136-
&& (!reportOutputDirectory.getAbsolutePath().endsWith("xref"))) {
137-
this.destDir = new File(reportOutputDirectory, "xref").getAbsolutePath();
138-
} else {
139-
this.destDir = reportOutputDirectory.getAbsolutePath();
140-
}
141-
}
142126
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.apache.maven.plugins.annotations.Mojo;
2424

2525
/**
26-
* Creates an html-based, cross referenced version of Java source code
26+
* Creates an HTML-based, cross referenced version of Java source code
2727
* for a project's test sources without forking. Note that this goal does require generation of test
2828
* sources before site generation, e.g. by invoking {@code }mvn clean deploy site}.
2929
*

0 commit comments

Comments
 (0)