[MPMD-390] Dynamically calculate xrefLocation/xrefTestLocation
diff --git a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
index 4816e9a..878e805 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
@@ -78,22 +78,26 @@
     protected String format = "xml";
 
     /**
-     * Link the violation line numbers to the source xref. Links will be created automatically if the jxr plugin is
+     * Link the violation line numbers to the (Test) Source XRef. Links will be created automatically if the JXR plugin is
      * being used.
      */
     @Parameter(property = "linkXRef", defaultValue = "true")
     private boolean linkXRef;
 
     /**
-     * Location of the Xrefs to link to.
+     * Location where Source XRef is generated for this project.
+     * <br>
+     * <strong>Default</strong>: {@link #getReportOutputDirectory()} + {@code /xref}
      */
-    @Parameter(defaultValue = "${project.reporting.outputDirectory}/xref")
+    @Parameter
     private File xrefLocation;
 
     /**
-     * Location of the Test Xrefs to link to.
+     * Location where Test Source XRef is generated for this project.
+     * <br>
+     * <strong>Default</strong>: {@link #getReportOutputDirectory()} + {@code /xref-test}
      */
-    @Parameter(defaultValue = "${project.reporting.outputDirectory}/xref-test")
+    @Parameter
     private File xrefTestLocation;
 
     /**
@@ -268,18 +272,18 @@
         return mojoExecution;
     }
 
-    protected String constructXRefLocation(boolean test) {
+    protected String constructXrefLocation(boolean test) {
         String location = null;
         if (linkXRef) {
-            File xrefLoc = test ? xrefTestLocation : xrefLocation;
+            File xrefLocation = getXrefLocation(test);
 
-            String relativePath =
-                    PathTool.getRelativePath(getReportOutputDirectory().getAbsolutePath(), xrefLoc.getAbsolutePath());
+            String relativePath = PathTool.getRelativePath(
+                    getReportOutputDirectory().getAbsolutePath(), xrefLocation.getAbsolutePath());
             if (relativePath == null || relativePath.isEmpty()) {
                 relativePath = ".";
             }
-            relativePath = relativePath + "/" + xrefLoc.getName();
-            if (xrefLoc.exists()) {
+            relativePath = relativePath + "/" + xrefLocation.getName();
+            if (xrefLocation.exists()) {
                 // XRef was already generated by manual execution of a lifecycle binding
                 location = relativePath;
             } else {
@@ -289,19 +293,24 @@
                         reporting != null ? reporting.getPlugins() : Collections.<ReportPlugin>emptyList();
                 for (ReportPlugin plugin : reportPlugins) {
                     String artifactId = plugin.getArtifactId();
-                    if ("maven-jxr-plugin".equals(artifactId) || "jxr-maven-plugin".equals(artifactId)) {
+                    if ("maven-jxr-plugin".equals(artifactId)) {
                         location = relativePath;
                     }
                 }
             }
 
             if (location == null) {
-                getLog().warn("Unable to locate Source XRef to link to - DISABLED");
+                getLog().warn("Unable to locate" + (test ? " Test" : "") + " Source XRef to link to - DISABLED");
             }
         }
         return location;
     }
 
+    protected File getXrefLocation(boolean test) {
+        File location = test ? xrefTestLocation : xrefLocation;
+        return location != null ? location : new File(getReportOutputDirectory(), test ? "xref-test" : "xref");
+    }
+
     /**
      * Convenience method to get the list of files where the PMD tool will be executed
      *
@@ -335,7 +344,7 @@
             for (String root : compileSourceRoots) {
                 File sroot = new File(root);
                 if (sroot.exists()) {
-                    String sourceXref = constructXRefLocation(false);
+                    String sourceXref = constructXrefLocation(false);
                     directories.add(new PmdFileInfo(project, sroot, sourceXref));
                 }
             }
@@ -348,7 +357,7 @@
             for (String root : testSourceRoots) {
                 File sroot = new File(root);
                 if (sroot.exists()) {
-                    String testXref = constructXRefLocation(true);
+                    String testXref = constructXrefLocation(true);
                     directories.add(new PmdFileInfo(project, sroot, testXref));
                 }
             }
@@ -359,7 +368,7 @@
                 for (String root : localCompileSourceRoots) {
                     File sroot = new File(root);
                     if (sroot.exists()) {
-                        String sourceXref = constructXRefLocation(false);
+                        String sourceXref = constructXrefLocation(false);
                         directories.add(new PmdFileInfo(localProject, sroot, sourceXref));
                     }
                 }
@@ -368,7 +377,7 @@
                     for (String root : localTestCompileSourceRoots) {
                         File sroot = new File(root);
                         if (sroot.exists()) {
-                            String testXref = constructXRefLocation(true);
+                            String testXref = constructXrefLocation(true);
                             directories.add(new PmdFileInfo(localProject, sroot, testXref));
                         }
                     }