PMD is very useful plugin to check the java code.
<project>
..........
<properties>
...........
<!-- When running PMD check with JDK 1.5 or 1.6, we will get like this warning "Can't use annotations when running in JDK 1.4 mode!". We can't see any PMD validation errors. To resolve this issue have set target jdk property as below -->
<targetJdk>1.5</targetJdk>
</properties>
............
<build>
<plugins>
..........
...........
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<inherited>true</inherited>
<configuration>
<!-- to skip PMD check set "true" -->
<skip>fasle</skip>
<!-- break the build when PMD found error, set "true" -->
<failOnViolation>true</failOnViolation>
<failurePriority>4</failurePriority>
<verbose>true</verbose>
<rulesets>
<!-- rule sets file -->
<ruleset>${basedir}/src/main/resources/pmd-rules.xml</ruleset>
</rulesets>
</configuration>
<!-- maven goals to execute -->
<executions>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>cpd-check</id>
<goals>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
.........
............
</plugins>
</build>
<!-- to resolve this warning "[WARNING] Unable to locate Source XRef to link to - DISABLED". With this warning PMD validation will work fine. -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
........
</project>
Comments
Post a Comment