You may have observed the following warnings when running the PMD or Checkstyle plugin:
[INFO] --- maven-pmd-plugin:3.2:pmd (default-cli) @ project-with-violations --- [WARNING] Unable to locate Source XRef to link to – DISABLED [INFO] --- maven-checkstyle-plugin:2.13:checkstyle (default-cli) @ project-with-violations --- [INFO] [INFO] There are 36 checkstyle errors. [WARNING] Unable to locate Source XRef to link to – DISABLED
The plugins attempt to link the violation to the specific lines in the cross-reference of the source. As they are unable to find this cross-reference, they display the warning.
To generate this cross-reference, we need to use the Maven JXR plugin.
Use the following steps to generate source references with the Maven JXR plugin:
mvn jxr:jxr
[INFO] [INFO] --- maven-jxr-plugin:2.5:jxr (default-cli) @ project-with-violations --- [INFO] ------------------------------------------------------------------------
target/site
folder.xref
folder in the browser:When the jxr
goal of the Maven JXR plugin is run, it generates a cross-reference of all the source files of the project. The format is similar to Javadoc, but on clicking on the class, you get to see the source code with the line numbers:
Once the cross-reference exists, code quality tools, such as PMD and Checkstyle, link to this reference automatically by using the following steps:
mvn jxr:jxr checkstyle:checkstyle
You can now see the line numbers against each of the violations, with the link to the line number in the cross-referenced source code.
18.188.178.181