使用 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"/>
但是,当运行这个 ant 目标时,我得到:
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 文件的一部分吗?我错过了什么?