The easiest way to run PMD is to just use a build plugin in your favorite build toollikeApache Ant,Apache Maven orGradle.
There are also many integrations for IDEs available, seeTools.
If you have your own build tool or want to integrate PMD in a different way, you can call PMD programmatically,as described here.
You’ll need to add the dependency to the language, you want to analyze. For Java, it will benet.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 propertypmdVersion
.
This will transitively pull in the artifactpmd-core
which contains the API.
The programmatic API for PMD is centered aroundPmdAnalysis
, please see the javadocs for usage information.
The programmatic API for CPD is centered aroundCpdAnalysis
, please see the javadocs for usage information.