2011-11-22 36 views
4

如何配置checkstyle(在Ant nt Maven中)任務?我嘗試了一下,但沒有正確地獲得報告。這是我的螞蟻腳本。如何在Hudson中爲Ant配置checkstyle confuguration?

<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:在執行這條線出現以下錯誤:\服務器\ build.xml文件:9725 C:\服務器\ build.xml文件:3838:得到56個錯誤和27599個警告。

你能指導我如何解決這個問題嗎?

感謝

回答

6

sun_checks.xml文件包含checkstyle configurations,即應評估你的源代碼時,可以應用的所有規則。

您的構建失敗,因爲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> 
+0

在哪裏設置這些道具'source.code.dir'&'base.working.dir'? – reiley