我希望 maven-pmd-plugin 包含我指定的规则集并排除一些规则(特别是 UselessParentheses)
就像文档中描述的那样,我将以下内容放在所有模块的父级 pmd.xml 中:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.0</version>
<configuration>
<rulesets>
<ruleset>/home/ubuntu/ruleset.xml</ruleset>
</rulesets>
</configuration>
</plugin>
</plugins>
</reporting>
并准备了一个这样的自定义规则集:
<!-- We'll use the entire rulesets -->
<rule ref="rulesets/java/basic.xml"/>
<rule ref="rulesets/java/imports.xml"/>
<rule ref="rulesets/java/codesize.xml"/>
<rule ref="rulesets/java/design.xml"/>
<rule ref="rulesets/java/strings.xml"/>
<rule ref="rulesets/java/unusedcode.xml"/>
<!-- We want everything from this except some -->
<rule ref="rulesets/java/unnecessary.xml">
<exclude name="UselessParentheses"/>
</rule>
作为主要部分。
然而,当我运行时,我mvn clean jxr:jxr pmd:check
在报告中有“UselessParentheses”。此外,用-X
节目运行它
[DEBUG] Preparing ruleset: java-basic
[DEBUG] Before: java-basic After: java-basic.xml
[DEBUG] The resource 'rulesets/java/basic.xml' was found as jar:file:/home/ubuntu/.m2/repository/net/sourceforge/pmd/pmd/5.0.2/pmd-5.0.2.jar!/rulesets/java/basic.xml.
[DEBUG] Preparing ruleset: java-unusedcode
[DEBUG] Before: java-unusedcode After: java-unusedcode.xml
[DEBUG] The resource 'rulesets/java/unusedcode.xml' was found as jar:file:/home/ubuntu/.m2/repository/net/sourceforge/pmd/pmd/5.0.2/pmd-5.0.2.jar!/rulesets/java/unusedcode.xml.
[DEBUG] Preparing ruleset: java-imports
[DEBUG] Before: java-imports After: java-imports.xml
[DEBUG] The resource 'rulesets/java/imports.xml' was found as jar:file:/home/ubuntu/.m2/repository/net/sourceforge/pmd/pmd/5.0.2/pmd-5.0.2.jar!/rulesets/java/imports.xml.
所以看起来 pmd 忽略了我的自定义规则集。
我希望自定义规则集起作用。我究竟做错了什么?