Guys, I wanted generate the pmd report while building the project so I have added plugin to build section of my pom.xml but still it don't execute until I explicitly call mvn clean install pmd:pmd. I want to execute it with mvn clean install itself. is it possible ? my pom entries are as under:
<build>
<plugins>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.4</version>
<configuration>
<skip>false</skip>
<targetJdk>${compile.source}</targetJdk>
<rulesets>
<ruleset>./current.pmd.rules.xml</ruleset>
</rulesets>
<excludes>
<exclude>com/cm/**/*.java</exclude>
<exclude>com/sm/**/*.java</exclude>
</excludes>
<linkXref>true</linkXref>
<failOnViolation>true</failOnViolation>
<executions>
<execution>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
开发者_StackOverflow中文版 </goals>
</execution>
</executions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.0.1</version>
</plugin>
</plugins>
</build>
Thanks in advance.
You can associate the pmd goals with install
phase by modifying your pom to contain the following snippet:
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
But you should associate it with a phase earlier than install
- like verify
- so that the checking happens before the install
phase.
hm sorry guys, its just a small mistake I have made while writing the configuration. The <executions> [...] </executions>
should be out of <configuration>[...]</configuration>
tag. Since the plugin is intelligent enough to execute it in verify
phase, we need not to associate it to any phase. We just need to include it in <build>
section of your pom.xml.
精彩评论