How to add PMD reporting to Maven

Before proceeding to this exercise, you may want to try my tutorial on how to setup a maven project to eclipse:

Assuming you have follow the tutorial above, you should have 1 maven project (ipiel) that contains 2 modules (ipiel-models, ipiel-portal), where portal is dependent to models.

Basically we would just add pmd configurations on ipiel-portal's pom.xml. Better take a look at this link:

4 Goals from the plugin:

Here's my ipiel-portal's new pom.xml, it has comments and it's straightforward so you shouldn't be confuse.
<project xmlns="" xmlns:xsi=""
 <name>Ipiel Portal</name>
 <description>Ipiel Portal</description>
       <!-- build will fail if error found on pmd -->
      <!-- Two rule sets that come bundled with PMD -->
       <!-- enable only 1 report -->
       <!-- <report>cpd</report> -->

After that, in eclipse create a new Run Configuration->Maven Build as follow,
You might want to add an empty try/catch block in your to test if PMD works then run pmd:check. It should generate several files inside target folder.

In my case it gives several error messages, and the build won't continue because I added a build fail statement in pom.xml's build section.
Here's the message:
Violation Line
  Avoid empty try blocks 13 - 15
  Avoid empty catch blocks 15 - 17
How to add PMD reporting to Maven How to add PMD reporting to Maven Reviewed by Edward Legaspi on Monday, April 09, 2012 Rating: 5

No comments:

Powered by Blogger.