Runs a set of static code analysis rules on some Java source code files and generates a list of problems found.
Attribute | Description | Required |
rulesetfiles | A comma delimited list of ruleset files ('rulesets/basic.xml,rulesets/design.xml'). If you write your own ruleset files, you can put them on the classpath and plug them in here. | Yes, unless the ruleset nested element is used |
failonerror | Whether or not to fail the build if any errors occur while processing the files | No |
failOnRuleViolation | Whether or not to fail the build if PMD finds any problems | No |
minimumPriority | The rule priority threshold; rules with lower priority than they will not be used | No |
shortFilenames | Places truncated filenames in the report. This can reduce your report file size by 15%-20%. | No |
targetjdk | Target JDK 1.3, 1.4, 1.5, 1.6, or jsp. "1.4" is the default. | No |
failuresPropertyName | A property name to plug the number of rule violations into when the task finishes | No |
encoding | The character set encoding (i.e., UTF-8) to use when reading the source code files | No |
excludemarker | The series of characters to use to tell PMD to skip lines - the default is NOPMD. | No |
formatter
nested element - specifies the format of and the files to which the report is written.
Name | Values |
---|---|
format | xml,html,text,csv,papari,summaryhtml |
showSuppressed | Whether to show suppressed warnings; "false" is the default. |
filename | A filename to which to write the report |
linkPrefix | Used for linking to online HTMLized source (like this). See example below. |
linePrefix | Used for linking to online HTMLized source (like this). See example below. |
classpath
nested element - useful for specifying custom rule. More details on the classpath
element are in the Ant documentation here and there's
an example below.
ruleset
nested element - another way to specify rulesets. Here's an example:
Several folks (most recently, Wouter Zelle) have written XSLT scripts which you can use to transform the XML report into nifty HTML. To do this, make sure you use the XML formatter in the PMD task invocation, i.e.:
Then, after the end of the PMD task, do this:
Running one ruleset to produce a HTML report (and printing the report to the console as well)
Running multiple rulesets to produce an XML report
Using a custom renderer
Using a classpath reference in the taskdef
Getting verbose output
An HTML report with the "linkPrefix" gizmo
An HTML report with the "linePrefix" gizmo