The PMD plugin performs quality checks on your project’s Java source files using PMD and generates reports from these checks.
Usage
To use the PMD plugin, include the following in your build script:
plugins {
id 'pmd'
}
plugins {
pmd
}
The plugin adds a number of tasks to the project that perform the quality checks. You can execute the checks by running gradle check
.
Note that PMD will run with the same Java version used to run Gradle.
Tasks
The PMD plugin adds the following tasks to the project:
The PMD plugin adds the following dependencies to tasks defined by the Java plugin.
Task name | Depends on |
---|---|
|
All PMD tasks, including |
Dependency management
The PMD plugin adds the following dependency configurations:
Name | Meaning |
---|---|
|
The PMD libraries to use |
|
The additional libraries that are available for type resolution during analysis. This might be useful if PMD complains about missing classes. |
Configuration
pmd {
consoleOutput = true
toolVersion = "6.21.0"
rulesMinimumPriority = 5
ruleSets = ["category/java/errorprone.xml", "category/java/bestpractices.xml"]
}
pmd {
isConsoleOutput = true
toolVersion = "6.21.0"
rulesMinimumPriority.set(5)
ruleSets = listOf("category/java/errorprone.xml", "category/java/bestpractices.xml")
}
See the PmdExtension class in the API documentation.