2012-11-30 21 views
5

Sử dụng pmd-5.0.1. Tôi có một số rulesets tùy chỉnh:Không thể tìm thấy ruleset/basic.xml khi sử dụng mục tiêu ant PMD

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

Các rulesets tham khảo nguyên tắc cơ bản như thế này:

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

Tuy nhiên, khi chạy mục tiêu kiến ​​này tôi nhận được:

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. 

nên không cơ bản. xml là một phần của tệp jar? Tôi đang thiếu gì?

Trả lời

13

Có vẻ như tôi đã căn cứ vào các quy tắc của mình trong phiên bản PMD lỗi thời. Hầu hết trong số họ được đặt tại rulesets/java/basic.xml/....

+0

thay đổi xảy ra với PMD 5.0 –

Các vấn đề liên quan