Table of Contents
The easiest way to run PMD is to just use a build plugin in your favorite build tool like Apache Ant, Apache Maven or Gradle.
There are also many integrations for IDEs available, see Tools.
If you have your own build tool or want to integrate PMD in a different way, you can call PMD programmatically, as described here.
Dependencies
You’ll need to add the dependency to the language, you want to analyze. For Java, it will be
net.sourceforge.pmd:pmd-java
. If you use Maven, you can add a new (compile time) dependency like this:
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${pmdVersion}</version>
</dependency>
Note: You’ll need to select a specific version. This is done in the example via the property pmdVersion
.
This will transitively pull in the artifact pmd-core
which contains the API.
Running PMD programmatically
The programmatic API for PMD is centered around PmdAnalysis
, please see the javadocs for usage information.
Running CPD programmatically
The programmatic API for CPD is centered around CpdAnalysis
, please see the javadocs for usage information.