Jenkins Ant 构建上的自定义 PMD rulset 文件不起作用



这是我尝试加载和引用规则集.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

我已经尝试了样式.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>

正如 adangel 在评论中发布的那样,答案是错别字,

由于"ms3k-build.pmd.rule.file"是一个属性,我会尝试像这样使用它: <pmd rulesetfiles="${xms3k-build.pmd.rule.file}" > – adangel

相关内容

  • 没有找到相关文章

最新更新