2013-05-20 37 views
1

我在添加checkstyle到我的構建文件時遇到了問題。我一直試圖按照教程http://checkstyle.sourceforge.net/anttask.html以及看看使用checkstyles並找到我的問題的解決方案的例子(如No output from Checkstyle in ANT),但是當我建立文件(終端命令ant編譯jar運行)時,什麼都沒有沿着checkstyle的路線似乎會發生。我想我已經將這些軟件包插入了正確的目錄。這裏是我的構建文件的代碼部分:Build中的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> 

如果有什麼我說不清楚,請讓我知道,我會嘗試澄清。非常感謝您的幫助。 :)

回答

3

確保以下文件存在:

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

我已經運行此版本文件及其正確給予違規行爲。