使用pmd-5.0.1。我有一些自定义规则集:
<target name="pmd">
<condition property="rules.file" else="${data}\pmdrules.xml,${data}\madcustompmdrules.xml">
<isset property="rules.file"/>
</condition>
<pmd rulesetfiles="${rules.file}">
<formatter type="xml" toFile="${report.file}"/>
<fileset dir="${src}">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>
规则集引用了这样的基本规则:
<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>
<rule ref="rulesets/basic.xml/JumbledIncrementer"/>
<rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
<rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>
<rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
然而,当我运行这个蚂蚁目标时,我得到:
java.lang.RuntimeException: Couldn't find the class Can't find resource rulesets/basic.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH.
basic.xml不应该成为jar文件的一部分吗?我错过了什么?
答案 0 :(得分:13)
看起来我的规则是基于过时版本的PMD。其中大多数位于rulesets/java/basic.xml/...
。