【问题标题】:Checkstyle Issues in Build构建中的 Checkstyle 问题
【发布时间】:2013-05-14 16:02:34
【问题描述】:

我在将 checkstyle 添加到我的构建文件时遇到了问题。我一直在尝试遵循http://checkstyle.sourceforge.net/anttask.html 的教程,并查看使用检查样式的代码示例并找到解决我的问题的方法(例如No output from Checkstyle in ANT),但是当我构建文件时(终端命令 ant compile jar运行),似乎没有发生任何类似于 checkstyle 的事情。我想我已经在正确的目录中插入了包。这是我的构建文件代码的一部分:

<property name="checkstyle.dir" location="home/lakers/NoteTaker/analysis/bin/checkstyle-5.6" /> 

...

   <target name="checkstyle">
    <taskdef resource="checkstyletask.properties">
    <classpath>
        <pathelement location="home/lakers/NoteTaker/analysis/bin"/>
        <pathelement location ="home/lakers/NoteTaker/analysis/bin/checkstyle-5.6/checkstyle-5.6-all.jar"/>
    </classpath>
    </taskdef>

    <echo>Starting checkstyle</echo>
    <checkstyle config="sun_checks.xml" failOnViolation="false">
        <fileset dir="src" includes="**/*.java"/>
        <fileset dir="NoteTaker/NoteTaker/src/notetaker" includes="**/*.java"/>
        <formatter type="plain"/>
    </checkstyle>
    <echo>Checkstyle finished</echo>
</target>

如果我说的有什么不清楚的地方,请告诉我,我会尽力澄清。非常感谢您的帮助。 :)

【问题讨论】:

    标签: xml ant build path checkstyle


    【解决方案1】:

    确保存在以下文件:

    1. checkstyle-5.6-all.jar -- 在-- home/lakers/NoteTaker/analysis/bin/checkstyle-5.6/checkstyle-5.6-all.jar,
    2. sun_checks.xml -- 在你的 -- base directory

    也许您错过了 sun_checks.xml 的正确目录。

    我已经制作了一个构建文件并且它可以正常工作。

    目录结构为:

    project
    |--------src
    |         |------packages/*.java files
    |
    |--------files
              |------checkstyle-all-5.6.jar
              |------sun_checks.xml
    

    我已将 checkstyle-all-5.6.jar 和 *sun_checks.xml* 复制到此项目目录。

    我的 build.xml 看起来像:

    <?xml version="1.0"?>
    <project name="XYZ" basedir="." default="job">
    
        <taskdef resource="checkstyletask.properties" classpath="${basedir}/files/checkstyle-5.6-all.jar" />
    
        <target name="job">
            <checkstyle config="files/sun_checks.xml"
                failureProperty="checkstyle.failure" failOnViolation="false">
                <fileset dir="src" includes="**/*.java" />
                <formatter type="plain" />
            </checkstyle>
    
            <echo>Job is Done</echo>
        </target>
    
    </project>
    

    我已经运行了这个构建文件并正确地给出了违规行为。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-05
      • 2020-07-17
      • 2021-01-29
      • 2019-05-04
      • 1970-01-01
      • 2017-06-02
      • 2018-03-19
      相关资源
      最近更新 更多