13 Eylül 2011 Salı

checkstyle ant task

checkstyle (http://checkstyle.sourceforge.net/) is a tool that hels java code to adhere to coding standards.

for checkstyle ant task: http://checkstyle.sourceforge.net/anttask.html



<property name="build.checkstyle.config" value="${config}/sun_checks.xml" />
<property name="build.checkstyle.output" value="${build.dir}/checkstyle_report.xml" />


<path id="checkstyle.classpath">
<pathelement location="${lib}/checkstyle-5.3.jar" />
<pathelement location="${lib}/google-collections-1.0.jar" />
<pathelement location="${lib}/commons-beanutils-core-1.8.3.jar" />
<pathelement location="${lib}/commons-logging-1.1.1.jar" />
<pathelement location="${lib}/antlr-2.7.7.jar" />
</path>


<target name="checkstyle" depends="init">
<taskdef resource="checkstyletask.properties" classpathref="checkstyle.classpath" />
<checkstyle failOnViolation="false" config="${build.checkstyle.config}">
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<formatter type="xml" tofile="${build.checkstyle.output}" />
</checkstyle>
</target>



about sun-checks.xml configuration file: http://checkstyle.sourceforge.net/config.html
here is a sample config file: http://code.google.com/p/checkstyle-idea/source/browse/trunk/src/main/resources/sun_checks.xml?r=120

Hiç yorum yok:

Yorum Gönder