Ant 为Jenkins启用Checkstyle的首选实践是什么?

Ant 为Jenkins启用Checkstyle的首选实践是什么?,ant,jenkins,checkstyle,Ant,Jenkins,Checkstyle,大家好:我注意到checkstyle有一个ant任务 我想在我的Ant构建中运行checkstyle,它在jenkins上 不幸的是,这些说明有点晦涩——涉及到启用项目依赖项、模块和其他特定于ant的配置。我有一个庞大的构建文件,我不是一个真正的构建工程师,所以我想保持它的简单,而不给脚本添加太多的bload Jenkins有一个很好的小按钮,它支持显示checkstyle结果,但是Jenkins要求您运行checkstyle,并在运行构建时自行配置它 修改build.xml和ivy.xml(

大家好:我注意到checkstyle有一个ant任务

我想在我的Ant构建中运行checkstyle,它在jenkins上

不幸的是,这些说明有点晦涩——涉及到启用项目依赖项、模块和其他特定于ant的配置。我有一个庞大的构建文件,我不是一个真正的构建工程师,所以我想保持它的简单,而不给脚本添加太多的bload

Jenkins有一个很好的小按钮,它支持显示checkstyle结果,但是Jenkins要求您运行checkstyle,并在运行构建时自行配置它


修改build.xml和ivy.xml(我假设我需要向ivy添加checkstyle以远程获取jar)的最简单方法是什么,以便在运行构建时对所有代码库进行基本的checkstyle分析

如何借助于just
Ant

<?xml version="1.0" encoding="UTF-8"?>
<project name="Build" default="build" basedir=".">

    <property file="props.properties"/>

    <taskdef resource="checkstyletask.properties" classpath="${checkstyle.jar.path}"/>

    <target name="build" depends="checkstyle">
        <echo>Starting build</echo>
        <echo>Build finished</echo>
    </target>
    <target name="checkstyle">
        <echo>Starting checkstyle</echo>
        <checkstyle config="rules/sun_checks.xml" failOnViolation="false">
            <fileset dir="src" includes="**/*.java"/>
            <formatter type="plain"/>
            <formatter type="xml" toFile="build/checkstyle_errors.xml"/>
        </checkstyle>
        <echo>Checkstyle finished</echo>
    </target>
</project>

开始构建
建成
开始检查样式
检查样式已完成
引述自:

failOnViolation-指定即使在 存在违规行为。默认为“true”

您可以从下载checkstyle-5.4-bin.zip。

分发包包含检查sun编码约定的
sun\u checks.xml
-
checkstyle配置
checkstyle-x.x-all.jar
带有任务引擎的库。

@jayunit100此行包含checkstyle jar的路径。这个jar包含
checkstyle
ant任务的代码。
checkstyle
不是Ant Apache的核心任务,因此它需要包含在类路径中。我认为您使用的是
Ivy
来存储项目依赖项,而不是存储Ant toolkit库。我从未使用过
jenkins
,但我认为您可以包含ant脚本并为其执行设置环境(属性)