Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

ant

pmd

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?

like image 533
mvd Avatar asked Nov 30 '12 22:11

mvd


1 Answers

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

like image 89
mvd Avatar answered Sep 30 '22 04:09

mvd