Hello all,
I've tried googling on this topic with no luck.
I need to run PMD on our source code base with one set of rules and on
the test code base with a different set. I created multiple executions
with customized configurations and I'm not seeing the results I'm
expecting.
What I thought it should be, based off the doc, is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<targetJdk>1.5</targetJdk>
<verbose>true</verbose>
<minimumPriority>1</minimumPriority>
<failurePriority>1</failurePriority>
</configuration>
<executions>
<execution>
<id>Source PMD Check</id>
<phase>compile</phase>
<goals>
<goal>pmd</goal>
</goals>
<configuration>
<rulesets>
<ruleset>/pmd-ruleset.xml</ruleset>
</rulesets>
</configuration>
</execution>
<execution>
<id>Test PMD Check</id>
<phase>test-compile</phase>
<goals>
<goal>pmd</goal>
</goals>
<configuration>
<rulesets>
<ruleset>/pmd-test-ruleset.xml</ruleset>
</rulesets>
<includeTests>true</includeTests>
<excludeRoots>
<excludeRoot>${basedir}/src/main/java</excludeRoot>
</excludeRoots>
</configuration>
</execution>
</executions>
</plugin>
I've tried multiple ways of configuring the plug-in, but the only way
I've gotten it close to what I want is with the configuration as below.
The problem is that it seems to run PMD twice.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<targetJdk>1.5</targetJdk>
<verbose>true</verbose>
<minimumPriority>1</minimumPriority>
<failurePriority>1</failurePriority>
</configuration>
<executions>
<execution>
<id>Source PMD Check</id>
<phase>verify</phase>
<goals>
<goal>pmd</goal>
<goal>check</goal>
</goals>
<configuration>
<rulesets>
<ruleset>/pmd-ruleset.xml</ruleset>
</rulesets>
<!-- In test-classes so it doesn't end up in the
jar -->
<targetDirectory>${project.build.directory}/test-classes</targetDirector
y>
</configuration>
</execution>
<execution>
<id>Test PMD Check</id>
<phase>test-compile</phase>
<goals>
<goal>pmd</goal>
<goal>check</goal>
</goals>
<configuration>
<rulesets>
<ruleset>/pmd-test-ruleset.xml</ruleset>
</rulesets>
<includeTests>true</includeTests>
<excludeRoots>
<excludeRoot>${basedir}/src/main/java</excludeRoot>
</excludeRoots>
<targetDirectory>${project.build.directory}/test-classes</targetDirector
y>
</configuration>
</execution>
</executions>
</plugin>
If I remove <targetDirectory> from either execution or if I set it to
simply ${project.build.directory}, I don't get failures I'm expecting.
Any help is appreciated.
Thanks,
Matt