The PMD report takes a long time to generate. Is there any way to skip the PMD or CPD reports temporarily?

Yes, each report supports a skip parameter which you can pass on the command line, -Dpmd.skip=true and -Dcpd.skip=true respectively.


How can I generate links to the JXR cross-referenced source?

First make sure that the linkXRef parameter is configured correctly (it is switched on by default).

Then, the jxr plugin has to run first so that the links can be picked up by the pmd report. If you run from the command line, use mvn jxr:jxr pmd:pmd, or if you want the reports generated by the site plugin, configure the jxr plugin in your reporting section, see JXR usage.


I have add the PMD/CPD reports, but they do not show up in the generated site. Has the plugin been executed?

If there are no violations, then by default no reports are created and the entire PMD or CPD section is not rendered in the site. To change this behaviour, set the skipEmptyReport for PMD or skipEmptyReport for CPD to false.


What's the difference between violations, failures and warnings and when is a build failing?

PMD reports violations. These violations originate from rules - the rules, that are enabled in the configured ruleset (see property rulesets). Each rule has a assigned priority (1 - high, 2 - medium-high, 3 - medium, 4 - medium-low, 5 - low). This priority is also used for the violation.

Violations with a high enough priority can fail the build when using the check goal. These violations are called "failures". The exact priority, when to fail the build, is configured via the property failurePriority.

Violations, that have a priority too low to fail the build, are called "warnings". These warnings appear in the report and are displayed in the build output, if the property verbose is enabled.

With the property failOnViolation the build failure can be entirely disabled. This is most useful at command line with -Dpmd.failOnViolation=false.

With the property maxAllowedViolations one can configure how many failures are allowed, before the build is failed.


What does the warning "The project xyz does not seem to be compiled. PMD results might be inaccurate." mean?

In order to improve PMD's results, type resolution should be used. It is enabled by default (property typeResolution) and helps to avoid false positive findings by matching the exact types of method parameters or variables.

However, this requires that the project is built first, so that not only the project's dependencies can be used for type resolution, but also the project's classes as well.

When using the property aggregate, this is problematic: With aggregate=true, PMD is executed at the root of a multi-module project before the individual modules are built. Then the types of the individual projects are not available, which might lead to false positive findings e.g. for the rule "UnusedPrivateMethod". If this might be the case, then the warning "The project xyz does not seem to be compiled. PMD results might be inaccurate" is issued.

In order to use type resolution and aggregate together, maven needs to be execute in two passes: First pass will compile the projects (e.g. mvn clean package) and the second pass will execute PMD without clean via the verify phase (e.g. mvn verify).

Since version 3.15.0 the new goal aggregate-pmd can be used which allows to run everything with only one maven call. However, this goal invokes the lifecycle test-compile before executing itself, which might lead to duplicated execution of some plugins.