简体   繁体   中英

Can not find ruleset/basic.xml when using PMD ant target

Using pmd-5.0.1. I have some custom rulesets:

<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>

The rulesets reference basic rules like this:

<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"/>

However, when running this ant target I get:

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.

Shouldn't basic.xml be part of the jar file? What am I missing?

Looks like I was basing my rules off an outdated version of PMD. Most of them are located at rulesets/java/basic.xml/... .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM