Wednesday, December 25, 2013

CheckStyle ANT Script

This is an example of CheckStyle ANT script.

<?xml version="1.0" encoding="UTF-8"?>

<!-- Description :This ANT script execute CheckStyle. -->
<project default="checkstyle.script" name="Example CheckStyle script.">
<property environment="env"/>
<property name="checkout.project.dir" value="C:/Program Files (x86)/Jenkins/jobs"/>
<property name="checkstyle.home" value="C:/checkstyle-5.6"/>
<property name="checkstyle.reports.dir" value="C:/reports"/>
<taskdef resource="checkstyletask.properties" classpath="${checkstyle.home}/checkstyle-5.6-all.jar"/>
<target name="checkstyle.run" depends="checkstyle.script"/> 
<target name="checkstyle.script">
<tstamp>
<format property="init_time" pattern="yyyy.MMM.dd ':' HH:mm:ss z" locale="en"/>
<format property="ext_time" pattern="yyyyMMMddHHmmss" locale="en"/>
</tstamp>
<move  failonerror="false" file="${checkstyle.reports.dir}/checkstyle.html" tofile="${checkstyle.reports.dir}/archives/checkstyle_${ext_time}.html"/>
<checkstyle config="${checkstyle.home}/sun_checks.xml" failureProperty="checkstyle.failure" failOnViolation="false">
<formatter type="xml" tofile="${checkstyle.reports.dir}/checkstyle.xml" />
<fileset dir="${checkout.project.dir}/workspace/src" includes="**/*.java" />
</checkstyle>
<xslt in="${checkstyle.reports.dir}/checkstyle.xml" out="${checkstyle.reports.dir}/checkstyle.html" style="${checkstyle.home}/contrib/checkstyle-noframes.xsl"/>
</target>

</project>

No comments:

Post a Comment