PMD-如何从违规检查中排除文件 [英] PMD - How to exclude files from violation check
问题描述
我们正在使用与验证"生命周期绑定的PMD检查"目标来检查代码. ( http://maven.apache.org/plugins/maven- pmd-plugin/examples/violationChecking.html )
We're checking our code using the PMD 'check' goal that is bound to the 'verify' life cycle. (http://maven.apache.org/plugins/maven-pmd-plugin/examples/violationChecking.html)
对于"pmd"目标,您可以添加"excludes"和"excludeRoots",但不能为"check"目标添加.
For the 'pmd' goal you can add 'excludes' and 'excludeRoots' but not for the 'check' goal.
如何排除例如生成的源目录?
How does one exclude eg. generated sources directories?
推荐答案
您需要先执行pmd:pmd,然后再执行pmd:check.您可以使用配置.将其绑定到验证之前的特定生命周期阶段.例如进入包装或集成前测试阶段.
You need to do the pmd:pmd first and afterwards do a pmd:check. You can configure that simply by using. Bind that to a particular lifecycle-phase which is before verify. For example into package or pre-integration-test phase.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<executions>
<execution>
<goals>
<goal>pmd</goal>
<goal>check</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
检查目标(检查,cpd-check的目的是在发生某些违规时使构建失败.因此,您可以为pmd目标定义一些例外,该例外应该包括/排除文件夹.
The check goals (check, cpd-check are exactly intended to fail a build if there are some violations. So you can define some exceptions for the pmd goal which folders should be included/excluded.
这篇关于PMD-如何从违规检查中排除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!