Question

I am using the maven-pmd-plugin on my project and this is how I have configured it

<reporting>
 <plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jxr-plugin</artifactId>
    <version>2.3</version>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>2.6</version>
    <configuration>
     <linkXref>true</linkXref>
     <sourceEncoding>UTF-8</sourceEncoding>
     <minimumTokens>100</minimumTokens>
     <targetJdk>${targetJdk}</targetJdk>
       <rulesets>
           <ruleset>${maven.pmd.rulesetfiles}</ruleset>
       </rulesets>
    </configuration>
  </plugin>
 </plugins>
</reporting>

Here are the properties used in the above configuration

<properties>
<spring.version>3.0.6.RELEASE</spring.version>
<basedir>C:\Users\Q4\workspace\project</basedir>
<maven.pmd.rulesetfiles>${basedir}\pmdRuleset.xml</maven.pmd.rulesetfiles>
<targetJdk>1.5</targetJdk>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

The problem is when I run mvn pmd:check, it gives me 8 violations -- only from the basic, unusedcode and imports. It simply doesn't use all the rules that I have listed in the custom ruleset file. I have even tried using the logging-java.xml and strings.xml directly in the ruleset without using the custom ruleset file and it still doesn't work.

When i run mvn pmd:pmd, i get a BUILD SUCCESS but the errors still show up in my target folder. Why do I get a build success here?

Was it helpful?

Solution

I solved this by simply adding the plugins in the build section along with the ones in the reporting section.

Somehow it needed to be in the as well to be able to run all the rulesets. Earlier I was under the impression that we put plugins in the build only if we want to run them during the build and deploy phase.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top