以下是我尝试加载和引用ruleset.xml文件的方法,
<property name="xms3k-build.pmd.rule.url" value="${xms3k-build.url}/${xms3k-build.version}/ruleset.xml" />
<property name="xms3k-build.pmd.rule.file" value="${xms3k-build.dir}/ruleset.xml" />
<!-- PMD static analysis task. -->
<target name="pmd" depends="compile, init-pmd">
<path id="pmd.aux.classpath">
<fileset dir="${lib.dir}/${ivy.conf.test}"/>
</path>
<pmd rulesetfiles="xms3k-build.pmd.rule.file" >
<formatter type="xml" toFile="pmd_report.xml" />
<fileset dir="${source.dir}">
<include name="**/*.java" />
</fileset>
<fileset dir="${source-test.dir}">
<include name="**/*.java" />
</fileset>
</pmd>
执行此行时发生以下错误:
common.xml:481: Can't find resource 'null' for rule 'xms3k-build.pmd.rule.file'.
Make sure the resource is a valid file or URL and is on the CLASSPATH. Here's the current classpath: /usr/share/java/ant.jar:/usr/share/java/ant-launcher.jar:/usr/share/java/jaxp_parser_impl.jar:/usr/share/java/xml-commons-apis.jar:/usr/share/java/junit.jar:/usr/share/java/ant/ant-junit.jar:/usr/share/java/junit.jar:/usr/share/java/ant/ant-junit4.jar:/usr/java/jdk1.7.0_45/lib/tools.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant-junit4.jar:/usr/share/ant/lib/ant-bootstrap.jar:/usr/share/ant/lib/ant-junit.jar
我尝试了很多style.xml文件的变种。以下是我目前正在尝试的内容:
<?xml version="1.0"?>
<ruleset name="Custom ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
This ruleset checks my code for bad stuff
</description>
<rule ref="rulesets/strings.xml"/>
</ruleset>
答案 0 :(得分:0)
正如adangel在评论中发表的那样,答案中的答案是错误的,
由于“ms3k-build.pmd.rule.file”属性,我尝试使用它:<pmd rulesetfiles="${xms3k-build.pmd.rule.file}" >
- adangel