我们可以在构建目标中包含 Maven pmd 插件执行吗?
伙计们,我想在构建项目时生成 pmd 报告,因此我添加了插件来构建我的 pom.xml 部分,但它仍然不会执行,直到我明确调用 mvn clean install pmd:pmd 。我想用 mvn clean install 本身来执行它。是否可以 ?我的 pom 条目如下:
<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>
</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>
提前致谢。
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>
</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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过修改 pom 以包含以下代码片段,将 pmd 目标与
install
阶段相关联:但您应该将其与早于
install
的阶段相关联 - 例如verify
- 以便检查发生在安装
阶段之前。You can associate the pmd goals with
install
phase by modifying your pom to contain the following snippet:But you should associate it with a phase earlier than
install
- likeverify
- so that the checking happens before theinstall
phase.嗯,抱歉,大家,这只是我在编写配置时犯的一个小错误。
; [...]
应该在[...]
标记之外。由于该插件足够智能,可以在验证阶段执行它,因此我们不需要将其关联到任何阶段。我们只需将其包含在 pom.xml 的
部分中。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 inverify
phase, we need not to associate it to any phase. We just need to include it in<build>
section of your pom.xml.