jenkins the definitive guide

(Jeff_L) #1
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<!-- PMD options -->
<targetJdk>1.6</targetJdk>
<aggregate>true</aggregate>
<format>xml</format>
<rulesets>
<ruleset>/pmd-rules.xml</ruleset>
</rulesets>

<!-- CPD options -->
<minimumTokens>50</minimumTokens>
<ignoreIdentifiers>true</ignoreIdentifiers>
</configuration>
</plugin>
</reportPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>com.wakaleo.code-quality</groupId>
<artifactId>pmd-rules</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

Now, you can run either mvn site or mvn pmd:pmd pmd:cpd to generate the PMD and CPD reports.


Unfortunately there is currently no built-in Gradle support for PMD or CPD, so you have to fall back
on invoking the PMD Ant plugin directly, as shown here:


configurations {
pmdConf
}

dependencies {
pmdConf 'pmd:pmd:4.2.5'
}

task pmd << {
println 'Running PMD static code analysis'
ant {
taskdef(name:'pmd', classname:'net.sourceforge.pmd.ant.PMDTask',
classpath: configurations.pmdConf.asPath)

taskdef(name:'cpd', classname:'net.sourceforge.pmd.cpd.CPDTask',
classpath: configurations.pmdConf.asPath)

pmd(shortFilenames:'true', failonruleviolation:'false',
rulesetfiles:'conf/pmd-rules.xml') {
formatter(type:'xml', toFile:'build/pmd.xml')
Free download pdf