@@ -78,22 +78,26 @@ public abstract class AbstractPmdReport extends AbstractMavenReport {
78
78
protected String format = "xml" ;
79
79
80
80
/**
81
- * Link the violation line numbers to the source xref . Links will be created automatically if the jxr plugin is
81
+ * Link the violation line numbers to the (Test) Source XRef . Links will be created automatically if the JXR plugin is
82
82
* being used.
83
83
*/
84
84
@ Parameter (property = "linkXRef" , defaultValue = "true" )
85
85
private boolean linkXRef ;
86
86
87
87
/**
88
- * Location of the Xrefs to link to.
88
+ * Location where Source XRef is generated for this project.
89
+ * <br>
90
+ * <strong>Default</strong>: {@link #getReportOutputDirectory()} + {@code /xref}
89
91
*/
90
- @ Parameter ( defaultValue = "${project.reporting.outputDirectory}/xref" )
92
+ @ Parameter
91
93
private File xrefLocation ;
92
94
93
95
/**
94
- * Location of the Test Xrefs to link to.
96
+ * Location where Test Source XRef is generated for this project.
97
+ * <br>
98
+ * <strong>Default</strong>: {@link #getReportOutputDirectory()} + {@code /xref-test}
95
99
*/
96
- @ Parameter ( defaultValue = "${project.reporting.outputDirectory}/xref-test" )
100
+ @ Parameter
97
101
private File xrefTestLocation ;
98
102
99
103
/**
@@ -279,18 +283,18 @@ protected MojoExecution getMojoExecution() {
279
283
return mojoExecution ;
280
284
}
281
285
282
- protected String constructXRefLocation (boolean test ) {
286
+ protected String constructXrefLocation (boolean test ) {
283
287
String location = null ;
284
288
if (linkXRef ) {
285
- File xrefLoc = test ? xrefTestLocation : xrefLocation ;
289
+ File xrefLocation = getXrefLocation ( test ) ;
286
290
287
- String relativePath =
288
- PathTool . getRelativePath ( getReportOutputDirectory ().getAbsolutePath (), xrefLoc .getAbsolutePath ());
291
+ String relativePath = PathTool . getRelativePath (
292
+ getReportOutputDirectory ().getAbsolutePath (), xrefLocation .getAbsolutePath ());
289
293
if (relativePath == null || relativePath .isEmpty ()) {
290
294
relativePath = "." ;
291
295
}
292
- relativePath = relativePath + "/" + xrefLoc .getName ();
293
- if (xrefLoc .exists ()) {
296
+ relativePath = relativePath + "/" + xrefLocation .getName ();
297
+ if (xrefLocation .exists ()) {
294
298
// XRef was already generated by manual execution of a lifecycle binding
295
299
location = relativePath ;
296
300
} else {
@@ -300,19 +304,24 @@ protected String constructXRefLocation(boolean test) {
300
304
reporting != null ? reporting .getPlugins () : Collections .<ReportPlugin >emptyList ();
301
305
for (ReportPlugin plugin : reportPlugins ) {
302
306
String artifactId = plugin .getArtifactId ();
303
- if ("maven-jxr-plugin" .equals (artifactId ) || "jxr-maven-plugin" . equals ( artifactId ) ) {
307
+ if ("maven-jxr-plugin" .equals (artifactId )) {
304
308
location = relativePath ;
305
309
}
306
310
}
307
311
}
308
312
309
313
if (location == null ) {
310
- getLog ().warn ("Unable to locate Source XRef to link to - DISABLED" );
314
+ getLog ().warn ("Unable to locate" + ( test ? " Test" : "" ) + " Source XRef to link to - DISABLED" );
311
315
}
312
316
}
313
317
return location ;
314
318
}
315
319
320
+ protected File getXrefLocation (boolean test ) {
321
+ File location = test ? xrefTestLocation : xrefLocation ;
322
+ return location != null ? location : new File (getReportOutputDirectory (), test ? "xref-test" : "xref" );
323
+ }
324
+
316
325
/**
317
326
* Convenience method to get the list of files where the PMD tool will be executed
318
327
*
@@ -346,7 +355,7 @@ protected Map<File, PmdFileInfo> getFilesToProcess() throws IOException {
346
355
for (String root : compileSourceRoots ) {
347
356
File sroot = new File (root );
348
357
if (sroot .exists ()) {
349
- String sourceXref = constructXRefLocation (false );
358
+ String sourceXref = constructXrefLocation (false );
350
359
directories .add (new PmdFileInfo (project , sroot , sourceXref ));
351
360
}
352
361
}
@@ -359,7 +368,7 @@ protected Map<File, PmdFileInfo> getFilesToProcess() throws IOException {
359
368
for (String root : testSourceRoots ) {
360
369
File sroot = new File (root );
361
370
if (sroot .exists ()) {
362
- String testXref = constructXRefLocation (true );
371
+ String testXref = constructXrefLocation (true );
363
372
directories .add (new PmdFileInfo (project , sroot , testXref ));
364
373
}
365
374
}
@@ -370,7 +379,7 @@ protected Map<File, PmdFileInfo> getFilesToProcess() throws IOException {
370
379
for (String root : localCompileSourceRoots ) {
371
380
File sroot = new File (root );
372
381
if (sroot .exists ()) {
373
- String sourceXref = constructXRefLocation (false );
382
+ String sourceXref = constructXrefLocation (false );
374
383
directories .add (new PmdFileInfo (localProject , sroot , sourceXref ));
375
384
}
376
385
}
@@ -379,7 +388,7 @@ protected Map<File, PmdFileInfo> getFilesToProcess() throws IOException {
379
388
for (String root : localTestCompileSourceRoots ) {
380
389
File sroot = new File (root );
381
390
if (sroot .exists ()) {
382
- String testXref = constructXRefLocation (true );
391
+ String testXref = constructXrefLocation (true );
383
392
directories .add (new PmdFileInfo (localProject , sroot , testXref ));
384
393
}
385
394
}
0 commit comments