我一直在阅读PMD Website所有references到<rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
,但我无法在basic.xml
找到文件pmd-bin-5.0.0
从sourceforge下载的pmd-bin-5.0-alpha
目录。
正如您在下面提供的屏幕转储中所看到的,我已经搜索了这个basic.xml
并空手而归。
Basic XML http://iforce.co.nz/i/m2nxe032.pto.png
在pmd-bin-5.0.0
的下一个屏幕截图中,没有名为规则集的文件夹
pmd directory http://iforce.co.nz/i/tsvpb3lo.uap.png
Pastebin link到ruleset.xml (24小时后过期)
<property name="pmd.dir" value="${basedir}/pmd" /><!-- directory that contains pmd.jar -->
<property name="pmd.test.results" location="${build.dir}/pmd"/>
<path id="pmd.lib" >
<fileset dir="${pmd.dir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="pmd" depends="compile" >
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.lib"/>
<pmd shortFilenames="true">
<ruleset>basic,imports</ruleset>
<formatter type="text" toFile="pmd-ant-results.txt"/>
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>
执行我的ant脚本后,会返回此错误
[pmd] net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource rulesets/basic.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH.
BUILD FAILED
C:\Users\Michael\Desktop\log4jassignment.s06005586\build.xml:131: 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.
Project Explorer
project http://iforce.co.nz/i/4sx5juq0.nm0.png
因此,它告诉我basic.xml
文件不是来自pmd-5.0.0.jar
文件,但实际上来自其他地方,因此我的问题是pmd basic.xml
的内容是什么,以及其他所需的xml文件(我的意思是如何抓住它们)?或者这些文件不存在我是不是想自己重新创建它们(如果是的话,我会怎么做呢?)
答案 0 :(得分:1)
我从PMD Website下载了pmd-bin-5.0-alpha.zip
。
解压缩pmd-bin-5.0-alpha.zip
文件后;
进入lib
目录并进入
尝试提取pmd-5.0-alpha.jar
。
我找到了following: