如何在Hudson中为Ant配置checkstyle confuguration?

Kar*_*ndi 4 ant hudson checkstyle

如何配置checkstyle(在Ant nt Maven中)任务?我尝试了一点,但我没有正确得到报告.这是我的蚂蚁脚本.

<target name="checkStyle">
    <taskdef resource="checkstyletask.properties">
        <classpath refid="compile.class.pathtest"/>
    </taskdef>

    <checkstyle config="${source.code.dir}/config/sun_checks.xml">
        <fileset dir="${base.working.dir}/JavaFolder">
            <include name="**/*.java"/>
        </fileset>
        <formatter type="plain"/>
        <formatter type="xml" toFile="checkstyle-result.xml"/>
    </checkstyle>
</target>

<path id="compile.class.pathtest">
    <pathelement location="${checkstyle.dir}/checkstyle-5.5-all.jar"/>
    <pathelement location="${checkstyle.dir}/checkstyle-5.5.jar"/>
    <pathelement location="${checkstyle.dir}/pmd-3.9.jar"/>
    <pathelement location="${checkstyle.dir}/asm-3.0.jar"/>
    <pathelement location="${checkstyle.dir}/backport-util-concurrent-2.1.jar"/>
    <pathelement location="${checkstyle.dir}/jaxen-1.1-beta-10.jar"/>
    <pathelement location="${checkstyle.dir}/saxpath-1.0-FCS.jar"/>
</path>
Run Code Online (Sandbox Code Playgroud)

什么是sun_checks.xml文件?我已经下载并保存在上面提到的文件夹中.在运行构建时,它会显示一些警告和错误.后来,它显示了这样.

建筑失败

C:\ server\build.xml:9725:执行此行时发生以下错误:C:\ server\build.xml:3838:得到56个错误和27599个警告.

你能指导我如何解决这个问题吗?

谢谢

oer*_*ers 6

sun_checks.xml文件包含checkstyle配置,即评估源代码时应应用的所有规则.

你的构建失败,因为checkstyle发现错误.

您可以将failOnViolation属性设置为false以避免这种情况.未设置时,此属性默认为true.

<checkstyle config="${source.code.dir}/config/sun_checks.xml" failOnViolation="false">
    <fileset dir="${base.working.dir}/JavaFolder">
        <include name="**/*.java"/>
    </fileset>
    <formatter type="plain"/>
    <formatter type="xml" toFile="checkstyle-result.xml"/>
</checkstyle>
Run Code Online (Sandbox Code Playgroud)