如何在 Hudson 中为 Ant 配置 checkstyle?

发布于 2024-12-17 06:48:27 字数 1409 浏览 3 评论 0原文

如何配置 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>

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

构建失败

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

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

谢谢

How can I configure checkstyle (in Ant nt Maven) task? I tried little bit but I didn't get the reports properly. Here's my ant script.

<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>

What's that sun_checks.xml file? I have downloaded and kept in the above mentioned folder. While running the build, it shows some warnings and errors. Later, it shows like this.

BUILD FAILED

C:\server\build.xml:9725: The following error occurred while executing this line:
C:\server\build.xml:3838: Got 56 errors and 27599 warnings.

Can you please guide me how to solve this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福还没到 2024-12-24 06:48:27

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>

The sun_checks.xml file contains the checkstyle configurations, i.e. all rules that should be applied when evaluating your source code.

Your build failes, because checkstyle found error.

You can set the failOnViolation property to false to avoid this. This property defaults to true, when it is not set.

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文