【问题标题】:How to integrate Ant with Checkstyle and PMD plug-ins in Jenkins如何在 Jenkins 中集成 Ant 与 Checkstyle 和 PMD 插件
【发布时间】:2017-12-05 15:31:33
【问题描述】:

我想在 Jenkins 中集成 Checkstyle 和 PMD 插件来自动检查代码质量。 我按照以下说明操作:http://www.treselle.com/blog/static-code-analysis-jenkins/

我在工作区中的 build.xml 附加了这些代码:

<taskdef name="checkstyle" classpath="WEB-INF/libs/checkstyle-5.6.jar" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" />
<target name="checkstyle" description="Generates a report of code convention violations.">
    <checkstyle config="sun_checks.xml" failOnViolation="false">
        <formatter type="xml" tofile="checkstyle_report.xml" />
        <fileset dir="WEB-INF/src" includes="**/*.java" />
    </checkstyle>
</target>
<taskdef name="pmd" classpath="WEB-INF/libs/pmd.jar" classname="net.sourceforge.pmd.ant.PMDTask" />
<target name="pmd" depends="compress">
    <pmd rulesetfiles="java-imports">
        <formatter type="xml" toFile="pmd_report.x.ml" />
        <fileset dir="WEB-INF/src">
            <include name="**/*.java" />
        </fileset>
    </pmd>
</target>

我也添加了足够多的库,但是在构建 Jobs 的时候,出现了异常:

taskdef class com.puppycrawl.tools.checkstyle.CheckStyleTask cannot be found using the classloader AntClassLoader[]

为什么会出现这样的错误?以及如何正确整合它们?

非常感谢!

【问题讨论】:

    标签: jenkins ant checkstyle pmd


    【解决方案1】:

    尝试使用更高版本的检查样式,如 checkstyle-8.0-all.jar。 见example

    【讨论】:

      【解决方案2】:

      classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" /> taskdef 类 com.puppycrawl.tools.checkstyle.CheckStyleTask 找不到

      该类名为CheckstyleAntTask

      有关如何使用 CheckstyleAntTask 的示例,请参阅 https://github.com/checkstyle/checkstyle/blob/master/config/ant-phase-verify.xml

      checkstyle-5.6.jar

      我建议升级到较新的版本。 Checkstyle 目前是第 8 版。

      【讨论】:

        猜你喜欢
        • 2013-05-31
        • 2010-09-16
        • 1970-01-01
        • 1970-01-01
        • 2015-04-27
        • 1970-01-01
        • 2017-07-30
        • 1970-01-01
        • 2019-03-14
        相关资源
        最近更新 更多