Linter Plugin

The Linter plugin runs static analysis tools on your project’s source code. Currently, it supports PMD for Java projects. The features of the plugin are also the public methods of the plugin class, so you can refer to the Groovy Doc for more information.

LATEST VERSION: 2.0.3

Loading the plugin

Here is how you load this plugin:

linter = loadPlugin(id: "org.savantbuild.plugin:linter:2.0.3")

Settings

The Linter plugin has one setting for the report output directory:

Report directory

The directory where analysis reports are written. This defaults to build/linter-reports:

linter.settings.reportDirectory = Paths.get("build/linter-reports")

Running PMD

The pmd method executes PMD analysis on your source code. At minimum, you must specify the rule sets to use:

linter.pmd(ruleSets: ["config/pmd-rules.xml"])

You can configure the analysis with additional attributes:

linter.pmd(
  ruleSets: ["config/pmd-rules.xml"],
  reportFormat: "html",
  reportFileName: "pmd-report",
  languageVersion: "17",
  inputPath: "src/main/java",
  minimumPriority: "MEDIUM",
  failOnViolations: true
)

PMD attributes

name description type required default
ruleSets Array of ruleset file paths (required) List<String> true -
reportFormat Output format: xml, html, or text String false xml
reportFileName Output report filename String false pmd-report
languageVersion Java language version String false 17
inputPath Source path to analyze String false src/main/java
sourceClassesPath Compiled classes path String false build/classes/main
testClassesPath Test classes path String false build/classes/test
cachePath PMD cache file path String false build/pmd.cache
minimumPriority Minimum violation priority String false MEDIUM
failOnViolations Whether to fail build on violations boolean false true
reportSuppressedViolations Include suppressed violations in report boolean false false
customRuleDependencySpecs Custom rule JAR dependency specs List<String> false []