Wednesday, February 6, 2013

Java Checkstyle with Xalan Formatter

An ANT script I created to parse Java with Checkstyle and then parse it with Xalan formatting it into HTML

<project name="Checkstyle Code Review and Reports"
    basedir="." default="runCodeReview" >
   
    <property name="home.dir" location="/home/euish7v/ae23d" />
    <property name="checkstyle.dir" location="${home.dir}/checkstyle-5.6/" />
    <property name="xalan.dir" location="${home.dir}/Downloads/xalan-j_2_7_0" />
   
    <target name="runCodeReview">
        <taskdef resource="checkstyletask.properties"
              classpath="${checkstyle.dir}/checkstyle-5.6-all.jar" />
         <checkstyle config="${checkstyle.dir}/sun_checks.xml"
                 failOnViolation="false">
            <fileset dir="src/main/java">
                <include name="**/*.java"/>
            </fileset>
            <formatter type="xml" toFile="checkstyle-result.xml"/>
        </checkstyle>
    </target>
   
    <target name="generateReport">
        <xslt basedir="." destdir="${checkstyle.dir}/html"
                style="${checkstyle.dir}/contrib/checkstyle-frames.xsl" >
            <classpath>
                    <fileset dir="${xalan.dir}">
                            <include name="*.jar"/>
                    </fileset>
            </classpath>
        </xslt>        
    </target>
</project>

No comments:

Post a Comment