【问题标题】:Can not find ruleset/basic.xml when using PMD ant target使用 PMD ant 目标时找不到 ruleset/basic.xml
【发布时间】:2012-11-30 22:16:42
【问题描述】:

使用 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 文件的一部分吗?我错过了什么?

【问题讨论】:

    标签: java ant pmd


    【解决方案1】:

    看起来我的规则是基于 PMD 的过时版本。其中大部分位于rulesets/java/basic.xml/...

    【讨论】:

    • 更改发生在 PMD 5.0
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    • 1970-01-01
    • 1970-01-01
    • 2012-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多