pmd:pmd
Note:
This goal should be used as a Maven report.
Full name:
org.apache.maven.plugins:maven-pmd-plugin:3.25.0:pmd
Description:
Creates a PMD site report based on the rulesets and configuration set in the plugin. It can also generate a pmd output file aside from the site report in any of the following formats: xml, csv or txt.
Attributes:
- Requires a Maven project to be executed.
- Requires dependency resolution of artifacts in scope:
test
. - The goal is thread-safe and supports parallel builds.
- Since version:
2.0
.
Required Parameters
Name | Type | Since | Description |
---|---|---|---|
<outputDirectory> |
File |
- |
The shared output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the shared output directory configured in the Maven Site Plugin is used instead.
A plugin may use any subdirectory structure (either using a hard-coded name or, ideally, an additional user-defined mojo parameter with a default value) to generate multi-page reports or external reports with the main output file (entry point) denoted by Default: ${project.build.directory}/reports |
<targetDirectory> |
File |
- |
The output directory for the intermediate XML report. User Property: project.build.directory |
Optional Parameters
Name | Type | Since | Description |
---|---|---|---|
<aggregate> |
boolean |
2.2 |
Deprecated. since 3.15.0 Use the goals pmd:aggregate-pmd and pmd:aggregate-cpd instead. See FAQ: Why do I get sometimes false positive and/or false negative violations? for an explanation.Whether to build an aggregated report at the root, or build individual reports. Default: false User Property: aggregate |
<analysisCache> |
boolean |
3.8 |
Enables the analysis cache, which speeds up PMD. This requires a cache file, that contains the results of the last PMD run. Thus the cache is only effective, if this file is not cleaned between runs. Default: false User Property: pmd.analysisCache |
<analysisCacheLocation> |
String |
3.8 |
The location of the analysis cache, if it is enabled. This file contains the results of the last PMD run and must not be cleaned between consecutive PMD runs. Otherwise the cache is not in use. If the file doesn't exist, PMD executes as if there is no cache enabled and all files are analyzed. Otherwise only changed files will be analyzed again. Default: ${project.build.directory}/pmd/pmd.cache User Property: pmd.analysisCacheLocation |
<benchmark> |
boolean |
3.1 |
Controls whether PMD will track benchmark information. Default: false User Property: pmd.benchmark |
<benchmarkOutputFilename> |
String |
3.1 |
Benchmark output filename. Default: ${project.build.directory}/pmd-benchmark.txt User Property: pmd.benchmarkOutputFilename |
<compileSourceRoots> |
List<String> |
3.7 |
Specifies the location of the source directories to be used for PMD. Defaults to project.compileSourceRoots .Default: ${project.compileSourceRoots} |
<excludeFromFailureFile> |
String |
3.7 |
File that lists classes and rules to be excluded from failures. For PMD, this is a properties file. For CPD, this is a text file that contains comma-separated lists of classes that are allowed to duplicate. User Property: pmd.excludeFromFailureFile |
<excludeRoots> |
File[] |
2.2 |
The project source directories that should be excluded. |
<excludes> |
List<String> |
2.2 |
A list of files to exclude from checking. Can contain Ant-style wildcards and double wildcards. Note that these exclusion patterns only operate on the path of a source file relative to its source root directory. In other words, files are excluded based on their package and/or class name. If you want to exclude entire source root directories, use the parameter excludeRoots instead. |
<format> |
String |
- |
Set the output format type, in addition to the HTML report. Must be one of: "none", "csv", "xml", "txt" or the full class name of the PMD renderer to use. See the net.sourceforge.pmd.renderers package javadoc for available renderers. XML is produced in any case, since this format is needed for the check goals (pmd:check, pmd:aggregator-check, pmd:cpd-check, pmd:aggregator-cpd-check). Default: xml User Property: format |
<includeTests> |
boolean |
2.2 |
Run PMD on the tests as well. Default: false |
<includeXmlInReports> |
boolean |
3.0 |
Whether to include the XML files generated by PMD/CPD in the org.apache.maven.reporting.AbstractMavenReport.getReportOutputDirectory() .Default: false |
<includes> |
List<String> |
2.2 |
A list of files to include from checking. Can contain Ant-style wildcards and double wildcards. Defaults to **\/*.java. |
<jdkToolchain> |
Map<String,String> |
3.14.0 |
Allow for configuration of the jvm used to run PMD via maven toolchains. This permits a configuration where the project is built with one jvm and PMD is executed with another. This overrules the toolchain selected by the maven-toolchain-plugin. Examples: (see Guide to Toolchains for more info)
note: requires at least Maven 3.3.1 |
<language> |
String |
3.0 |
The programming language to be analyzed by PMD. Valid values are currently java , javascript and jsp .Default: java |
<linkXRef> |
boolean |
- |
Link the violation line numbers to the (Test) Source XRef. Links will be created automatically if the JXR plugin is being used. Default: true User Property: linkXRef |
<locale> |
String |
- |
The locale to use when the report generation is invoked directly as a standalone Mojo. See also: SiteTool#DEFAULT_LOCALE, SiteTool#getSiteLocales(String) Default: default |
<minimumPriority> |
int |
2.1 |
The rule priority threshold; rules with lower priority than this will not be evaluated. Default: 5 User Property: minimumPriority |
<outputFormat> |
String |
- |
The report output format: null by default, to represent a site, but can be configured to a Doxia Sink id. User Property: output.format |
<outputTimestamp> |
String |
- |
Timestamp for reproducible output archive entries, either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).Default: ${project.build.outputTimestamp} |
<renderProcessingErrors> |
boolean |
3.9.0 |
Also render processing errors into the HTML report. Processing errors are problems, that PMD encountered while executing the rules. It can be parsing errors or exceptions during rule execution. Processing errors indicate a bug in PMD and the information provided help in reporting and fixing bugs in PMD. Default: true User Property: pmd.renderProcessingErrors |
<renderRuleViolationPriority> |
boolean |
3.10.0 |
Also render the rule priority into the HTML report. Default: true User Property: pmd.renderRuleViolationPriority |
<renderSuppressedViolations> |
boolean |
3.17.0 |
Add a section in the HTML report that lists the suppressed violations. Default: true User Property: pmd.renderSuppressedViolations |
<renderViolationsByPriority> |
boolean |
3.12.0 |
Add a section in the HTML report, that groups the found violations by rule priority in addition to grouping by file. Default: true User Property: pmd.renderViolationsByPriority |
<rulesets> |
String[] |
- |
The PMD rulesets to use. See the Stock Java Rulesets for a list of available rules. Defaults to a custom ruleset provided by this maven plugin (/rulesets/java/maven-pmd-plugin-default.xml ). |
<rulesetsTargetDirectory> |
File |
3.13.0 |
Before PMD is executed, the configured rulesets are resolved and copied into this directory.
Note: Before 3.13.0, this was by default ${project.build.directory}. Default: ${project.build.directory}/pmd/rulesets User Property: pmd.rulesetsTargetDirectory |
<showPmdLog> |
boolean |
3.9.0 |
Deprecated. With 3.22.0 and the upgrade to PMD 7, this parameter has no effect anymore. The PMD log is now always redirected into the maven log and this can't be disabled by this parameter anymore. In order to disable the logging, see Maven Logging. You'd need to start maven with MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.net.sourceforge.pmd=off mvn <goals> .Redirect PMD log into maven log out. When enabled, the PMD log output is redirected to maven, so that it is visible in the console together with all the other log output. Also, if maven is started with the debug flag ( -X or --debug ), the PMD logger is also configured for debug.Default: true User Property: pmd.showPmdLog |
<siteDirectory> |
File |
- |
Directory containing the site.xml file.Default: ${basedir}/src/site |
<skip> |
boolean |
2.1 |
Skip the PMD report generation. Most useful on the command line via "-Dpmd.skip=true". Default: false User Property: pmd.skip |
<skipEmptyReport> |
boolean |
3.1 |
Skip the PMD/CPD report generation if there are no violations or duplications found. Defaults to false .
Note: the default value was changed from Default: false |
<skipPmdError> |
boolean |
3.1 |
per default pmd executions error are ignored to not break the whole Default: true User Property: pmd.skipPmdError |
<suppressMarker> |
String |
3.4 |
Source level marker used to indicate whether a RuleViolation should be suppressed. If it is not set, PMD's default will be used, which is NOPMD . See also PMD – Suppressing warnings.User Property: pmd.suppressMarker |
<targetJdk> |
String |
- |
The target JDK to analyze based on. Should match the source used in the compiler plugin. Valid values depend on the used PMD version. Most common values are 8 , 11 , 17 , and 21 .
The full list of supported Java versions for each PMD version is available at Java support (PMD). You can override the default PMD version by specifying PMD as a dependency, see Upgrading PMD at Runtime. Note: this parameter is only used if the language parameter is set to Default: ${maven.compiler.source} User Property: targetJdk |
<testSourceRoots> |
List<String> |
3.7 |
The directories containing the test-sources to be used for PMD. Defaults to project.testCompileSourceRoots Default: ${project.testCompileSourceRoots} |
<typeResolution> |
boolean |
3.0 |
Controls whether the project's compile/test classpath should be passed to PMD to enable its type resolution feature. Default: true User Property: pmd.typeResolution |
<xrefLocation> |
File |
- |
Location where Source XRef is generated for this project.
Default: org.apache.maven.reporting.AbstractMavenReport.getReportOutputDirectory() + /xref |
<xrefTestLocation> |
File |
- |
Location where Test Source XRef is generated for this project.
Default: org.apache.maven.reporting.AbstractMavenReport.getReportOutputDirectory() + /xref-test |
Parameter Details
<aggregate>
since 3.15.0 Use the goals
pmd:aggregate-pmd
and pmd:aggregate-cpd
instead. See FAQ: Why do I get sometimes false positive and/or false negative violations? for an explanation.- Type:
boolean
- Since:
2.2
- Required:
No
- User Property:
aggregate
- Default:
false
<analysisCache>
- Type:
boolean
- Since:
3.8
- Required:
No
- User Property:
pmd.analysisCache
- Default:
false
<analysisCacheLocation>
- Type:
java.lang.String
- Since:
3.8
- Required:
No
- User Property:
pmd.analysisCacheLocation
- Default:
${project.build.directory}/pmd/pmd.cache
<benchmark>
- Type:
boolean
- Since:
3.1
- Required:
No
- User Property:
pmd.benchmark
- Default:
false
<benchmarkOutputFilename>
- Type:
java.lang.String
- Since:
3.1
- Required:
No
- User Property:
pmd.benchmarkOutputFilename
- Default:
${project.build.directory}/pmd-benchmark.txt
<compileSourceRoots>
project.compileSourceRoots
.- Type:
java.util.List<java.lang.String>
- Since:
3.7
- Required:
No
- Default:
${project.compileSourceRoots}
<excludeFromFailureFile>
- Type:
java.lang.String
- Since:
3.7
- Required:
No
- User Property:
pmd.excludeFromFailureFile
<excludeRoots>
- Type:
java.io.File[]
- Since:
2.2
- Required:
No
<excludes>
excludeRoots
instead.- Type:
java.util.List<java.lang.String>
- Since:
2.2
- Required:
No
<format>
- Type:
java.lang.String
- Required:
No
- User Property:
format
- Default:
xml
<includeTests>
- Type:
boolean
- Since:
2.2
- Required:
No
- Default:
false
<includeXmlInReports>
org.apache.maven.reporting.AbstractMavenReport.getReportOutputDirectory()
.- Type:
boolean
- Since:
3.0
- Required:
No
- Default:
false
<includes>
- Type:
java.util.List<java.lang.String>
- Since:
2.2
- Required:
No
<jdkToolchain>
Allow for configuration of the jvm used to run PMD via maven toolchains. This permits a configuration where the project is built with one jvm and PMD is executed with another. This overrules the toolchain selected by the maven-toolchain-plugin.
Examples:
(see Guide to Toolchains for more info)
<configuration>
...
<jdkToolchain>
<version>1.11</version>
</jdkToolchain>
</configuration>
<configuration>
...
<jdkToolchain>
<version>1.8</version>
<vendor>zulu</vendor>
</jdkToolchain>
</configuration>
note: requires at least Maven 3.3.1- Type:
java.util.Map<java.lang.String, java.lang.String>
- Since:
3.14.0
- Required:
No
<language>
java
, javascript
and jsp
.- Type:
java.lang.String
- Since:
3.0
- Required:
No
- Default:
java
<linkXRef>
- Type:
boolean
- Required:
No
- User Property:
linkXRef
- Default:
true
<locale>
See also: SiteTool#DEFAULT_LOCALE, SiteTool#getSiteLocales(String)
- Type:
java.lang.String
- Required:
No
- Default:
default
<minimumPriority>
- Type:
int
- Since:
2.1
- Required:
No
- User Property:
minimumPriority
- Default:
5
<outputDirectory>
A plugin may use any subdirectory structure (either using a hard-coded name or, ideally, an additional user-defined mojo parameter with a default value) to generate multi-page reports or external reports with the main output file (entry point) denoted by #getOutputName()
.
- Type:
java.io.File
- Required:
Yes
- Default:
${project.build.directory}/reports
<outputFormat>
- Type:
java.lang.String
- Required:
No
- User Property:
output.format
<outputTimestamp>
yyyy-MM-dd'T'HH:mm:ssXXX
or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).- Type:
java.lang.String
- Required:
No
- Default:
${project.build.outputTimestamp}
<renderProcessingErrors>
- Type:
boolean
- Since:
3.9.0
- Required:
No
- User Property:
pmd.renderProcessingErrors
- Default:
true
<renderRuleViolationPriority>
- Type:
boolean
- Since:
3.10.0
- Required:
No
- User Property:
pmd.renderRuleViolationPriority
- Default:
true
<renderSuppressedViolations>
- Type:
boolean
- Since:
3.17.0
- Required:
No
- User Property:
pmd.renderSuppressedViolations
- Default:
true
<renderViolationsByPriority>
- Type:
boolean
- Since:
3.12.0
- Required:
No
- User Property:
pmd.renderViolationsByPriority
- Default:
true
<rulesets>
/rulesets/java/maven-pmd-plugin-default.xml
).- Type:
java.lang.String[]
- Required:
No
<rulesetsTargetDirectory>
Note: Before 3.13.0, this was by default ${project.build.directory}.
- Type:
java.io.File
- Since:
3.13.0
- Required:
No
- User Property:
pmd.rulesetsTargetDirectory
- Default:
${project.build.directory}/pmd/rulesets
<showPmdLog>
With 3.22.0 and the upgrade to PMD 7, this parameter has no effect anymore. The PMD log is now always redirected into the maven log and this can't be disabled by this parameter anymore. In order to disable the logging, see Maven Logging. You'd need to start maven with
MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.net.sourceforge.pmd=off mvn <goals>
.-X
or --debug
), the PMD logger is also configured for debug.- Type:
boolean
- Since:
3.9.0
- Required:
No
- User Property:
pmd.showPmdLog
- Default:
true
<siteDirectory>
site.xml
file.- Type:
java.io.File
- Required:
No
- Default:
${basedir}/src/site
<skip>
- Type:
boolean
- Since:
2.1
- Required:
No
- User Property:
pmd.skip
- Default:
false
<skipEmptyReport>
false
.
Note: the default value was changed from true
to false
with version 3.13.0.
- Type:
boolean
- Since:
3.1
- Required:
No
- Default:
false
<skipPmdError>
- Type:
boolean
- Since:
3.1
- Required:
No
- User Property:
pmd.skipPmdError
- Default:
true
<suppressMarker>
NOPMD
. See also PMD – Suppressing warnings.- Type:
java.lang.String
- Since:
3.4
- Required:
No
- User Property:
pmd.suppressMarker
<targetDirectory>
- Type:
java.io.File
- Required:
Yes
- User Property:
project.build.directory
<targetJdk>
8
, 11
, 17
, and 21
.
The full list of supported Java versions for each PMD version is available at Java support (PMD).
You can override the default PMD version by specifying PMD as a dependency, see Upgrading PMD at Runtime.
Note: this parameter is only used if the language parameter is set to java
.
- Type:
java.lang.String
- Required:
No
- User Property:
targetJdk
- Default:
${maven.compiler.source}
<testSourceRoots>
project.testCompileSourceRoots
- Type:
java.util.List<java.lang.String>
- Since:
3.7
- Required:
No
- Default:
${project.testCompileSourceRoots}
<typeResolution>
- Type:
boolean
- Since:
3.0
- Required:
No
- User Property:
pmd.typeResolution
- Default:
true
<xrefLocation>
Default:
org.apache.maven.reporting.AbstractMavenReport.getReportOutputDirectory()
+ /xref
- Type:
java.io.File
- Required:
No
<xrefTestLocation>
Default:
org.apache.maven.reporting.AbstractMavenReport.getReportOutputDirectory()
+ /xref-test
- Type:
java.io.File
- Required:
No