checkstyle/build.xml

714 lines
27 KiB
XML

<project name="checkstyle" default="compile.checkstyle" basedir=".">
<!-- set global properties for this build -->
<!-- Give user a chance to override without editing this file -->
<!-- (and without typing -D each time it compiles it) -->
<property file="checkstyle.buildproperties" />
<property file="${user.home}/checkstyle.buildproperties" />
<property name="ant.jar" value="${ant.home}/lib/ant.jar" />
<property name="crimson.jar" value="${ant.home}/lib/crimson.jar" />
<property name="xerces.jar" value="${ant.home}/lib/xercesImpl.jar" />
<property name="xml-apis.jar" value="${ant.home}/lib/xml-apis.jar" />
<property name="antlr.jar" value="lib/antlr.jar" />
<property name="velocity.jar" value="lib/velocity-dep-1.4.jar" />
<property name="jdom.jar" value="lib/jdom-b9.jar" />
<property name="regexp.jar" value="lib/jakarta-regexp-1.3.jar" />
<property name="junit.jar" value="lib/junit.jar" />
<property name="beanutils.jar" value="lib/commons-beanutils.jar" />
<property name="collections.jar" value="lib/commons-collections.jar" />
<property name="cli.jar" value="lib/commons-cli.jar" />
<property name="logging.jar" value="lib/commons-logging.jar" />
<property name="clover.lib" location="/apps/clover-1.1.1/lib"/>
<property name="tools.jar" value="${java.home}/../lib/tools.jar" />
<property name="checkstyle.dir"
value="src/checkstyle/com/puppycrawl/tools/checkstyle" />
<property name="checkstyle.grammar.dir"
value="${checkstyle.dir}/grammars" />
<property name="testreport.dir" value="target/testreports"/>
<property name="dist.dir" value="target/dist"/>
<property name="xdocs.src" value="src/xdocs"/>
<property name="xdocs.dest" value="target/thedocs"/>
<property name="version" value="3.5" />
<path id="build.classpath">
<pathelement location="${antlr.jar}" />
<pathelement location="${regexp.jar}" />
<pathelement location="${collections.jar}" />
<pathelement location="${cli.jar}" />
<pathelement location="${beanutils.jar}" />
<pathelement location="${logging.jar}" />
<pathelement location="${ant.jar}" />
<pathelement location="${tools.jar}" />
</path>
<path id="run.classpath">
<pathelement location="target/checkstyle" />
<pathelement location="${antlr.jar}" />
<path refid="build.classpath" />
</path>
<!-- add classes to generate Javadoc -->
<path id="javadoc.classpath">
<pathelement location="${crimson.jar}" />
<path refid="run.classpath" />
</path>
<path id="tests.buildpath">
<pathelement location="${junit.jar}" />
<path refid="run.classpath" />
</path>
<path id="tests.runpath">
<pathelement location="target/tests" />
<pathelement path="${clover.lib}/clover.jar"/>
<pathelement path="${xerces.jar}"/>
<pathelement path="${xml-apis.jar}"/>
<path refid="tests.buildpath" />
</path>
<path id="velocity.classpath">
<pathelement location="${velocity.jar}"/>
<pathelement location="${jdom.jar}" />
</path>
<target name="display.classpath" description="Displays the run classpath">
<property name="asd" refid="run.classpath" />
<echo message="Classpath is ${asd}" />
</target>
<!-- -->
<!-- Cleanup targets -->
<!-- -->
<target name="clean" description="Cleans any directories and generated files">
<delete>
<fileset dir="src/checkstyle">
<include name="**/Generated*.java"/>
<include name="**/Generated*.txt"/>
<include name="**/expandedjava14.g"/>
</fileset>
</delete>
<delete dir="target" />
<delete includeemptydirs="true">
<fileset dir="docs/api" includes="**" excludes=".cvsignore,CVS/**"/>
</delete>
</target>
<!-- -->
<!-- ANTLR targets -->
<!-- -->
<!-- Checks whether the grammar file is newer that the generated code -->
<target name="check.antlr"
description="Checks whether the grammar file is newer that the generated code">
<uptodate property="uptodate.antlr"
targetfile="${checkstyle.grammar.dir}/GeneratedJava14Lexer.java" >
<srcfiles dir= "${checkstyle.grammar.dir}" includes="java_new.g,java14_new.g,java.g,java14.g"/>
</uptodate>
</target>
<!-- Conditionally will compile the grammar. Deliberately do not use the -->
<!-- antlr task as it requirs the ANTLR classes to be in the classpath -->
<!-- which creates lots of problems. -->
<target name="build.antlr" depends="check.antlr" unless="uptodate.antlr"
description="Conditionally compiles the grammar files">
<java classname="antlr.Tool"
classpath="${antlr.jar}"
fork="yes"
failonerror="true"
dir="${checkstyle.grammar.dir}">
<arg value="java.g" />
</java>
<java classname="antlr.Tool"
classpath="${antlr.jar}"
fork="yes"
failonerror="true"
dir="${checkstyle.grammar.dir}">
<arg value="-glib" />
<arg value="java.g" />
<arg value="java14.g" />
</java>
</target>
<!-- -->
<!-- COMPILE TARGETS -->
<!-- -->
<target name="compile.checkstyle" depends="build.antlr"
description="Compiles the source code">
<mkdir dir="target/checkstyle" />
<depend srcdir="src/checkstyle"
destdir="target/checkstyle" closure="yes"/>
<javac srcdir="src/checkstyle"
destdir="target/checkstyle"
deprecation="on" debug="on"
classpathref="build.classpath"
includeAntRuntime="false"/>
<propertyfile file="target/checkstyle/checkstylecompilation.properties">
<entry key="checkstyle.compile.version" value="${version}"/>
<entry key="checkstyle.compile.timestamp" type="date" value="now" pattern="E MMMM dd yyyy, HH:mm z"/>
</propertyfile>
<native2ascii src="src/checkstyle"
dest="target/checkstyle"
encoding="EUC-JP"
includes="**/*_ja.properties" />
<copy todir="target/checkstyle">
<fileset dir="src/checkstyle" includes="**/*.properties"/>
<fileset dir="src/checkstyle" includes="**/*.xml"/>
<fileset dir="src/checkstyle" includes="**/*.dtd"/>
</copy>
<!-- fix for bug #594469:
create a copy of the english property file, necessary to run
the tests in an environment that has a supported language (e.g. de)
in the default locale. See algorithm in ResourceBundle.getBundle() -->
<copy todir="target/checkstyle" >
<fileset dir="src/checkstyle" includes="**/messages.properties"/>
<mapper type="glob" from="*messages.properties" to="*messages_en.properties"/>
</copy>
<javadoc sourcefiles="src/checkstyle/com/puppycrawl/tools/checkstyle/api/TokenTypes.java"
classpathref="javadoc.classpath"
failonerror="yes">
<doclet name="com.puppycrawl.tools.checkstyle.doclets.TokenTypesDoclet"
path="target/checkstyle">
<param name="-destfile" value="${basedir}/target/checkstyle/com/puppycrawl/tools/checkstyle/api/tokentypes.properties"/>
</doclet>
</javadoc>
</target>
<target name="compile.testinputs" description="Compile test inputs">
<mkdir dir="target/testinputs" />
<depend srcdir="src/testinputs" destdir="target/testinputs" closure="yes"/>
<!-- start of a change to turn on compilation of all input files -->
<!-- under JDK1.4. -->
<property name="testExcludes"
value="**/InputWhitespace.java,**/InputImport.java"/>
<javac srcdir="src/testinputs"
destdir="target/testinputs"
deprecation="on" debug="on"
excludes="${testExcludes}"
includeAntRuntime="false"/>
</target>
<!-- Compiles only the test code. Input files are excluded from
compilation, they contain code like assert statements
that does not compile on all JDKs -->
<target name="compile.tests" depends="compile.checkstyle"
description="Compiles the test code">
<!-- don't instrument the tests -->
<property name="clover.enable" value="false"/>
<mkdir dir="target/tests" />
<depend srcdir="src/tests" destdir="target/tests" closure="yes"/>
<javac srcdir="src/tests"
destdir="target/tests"
deprecation="on" debug="on"
classpathref="tests.buildpath"
includeAntRuntime="false"/>
</target>
<!-- -->
<!-- TEST TARGETS -->
<!-- -->
<!-- Run the GUI -->
<target name="run.gui" depends="compile.checkstyle"
description="Run the GUI for displaying a tree">
<java classname="com.puppycrawl.tools.checkstyle.gui.Main"
fork="yes" classpathref="run.classpath">
</java>
</target>
<!-- runs the command line version on a file -->
<target name="run.checkstyle" depends="compile.tests"
description="Runs the command line version on a file">
<java classname="com.puppycrawl.tools.checkstyle.Main"
fork="yes"
dir="."
classpathref="run.classpath">
<sysproperty key="checkstyle.allow.tabs" value="yes"/>
<arg value="-c"/>
<arg file="docs/checkstyle_checks.xml"/>
<arg value="src/testinputs/com/puppycrawl/tools/checkstyle/InputSimple.java"/>
</java>
<java classname="com.puppycrawl.tools.checkstyle.Main"
fork="yes"
dir="."
classpathref="run.classpath">
<arg value="-c"/>
<arg file="docs/checkstyle_checks.xml"/>
<arg value="-r"/>
<arg file="src/checkstyle/com/puppycrawl/tools/checkstyle/api"/>
</java>
</target>
<target name="enable.todo" description="Will enable checking for TODO's">
<property name="todo.pattern" value="TODO:"/>
</target>
<target name="checkstyle.checkstyle" depends="compile.checkstyle"
description="Runs checkstyle against it's own sources">
<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
<classpath refid="run.classpath"/>
</taskdef>
<delete file="target/cachefile" />
<property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
<property name="check.config" location="docs/checkstyle_checks.xml"/>
<property name="translation.severity" value="error"/>
<checkstyle config="${check.config}">
<fileset dir="src/checkstyle"
includes="**/*.java,**/*.properties"
excludes="**/Generated*.java,**/gui/*,**/transmogrify/*"/>
<formatter type="plain"/>
<formatter type="xml" toFile="target/cs_errors.xml"/>
<classpath refid="run.classpath"/>
<property key="checkstyle.cache.file" file="target/cachefile"/>
<property key="checkstyle.header.file" file="docs/java.header"/>
<property key="checkstyle.suppressions.file"
file="docs/suppressions.xml"/>
</checkstyle>
</target>
<target name="checkstyle.style" depends="compile.checkstyle"
description="Runs checkstyle against it's own sources to test generation of error reports">
<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
<classpath refid="run.classpath"/>
</taskdef>
<delete file="target/cachefile" />
<property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
<property name="check.config" location="docs/checkstyle_checks.xml"/>
<property name="translation.severity" value="error"/>
<checkstyle failonviolation="false" config="${check.config}">
<fileset dir="src/checkstyle"
includes="**/*.java,**/*.properties"
excludes="**/Generated*.java,**/gui/*,,**/transmogrify/*"/>
<formatter type="xml" toFile="target/cs_errors.xml"/>
<classpath refid="run.classpath"/>
<property key="checkstyle.cache.file" file="target/cachefile"/>
<property key="checkstyle.header.file" file="docs/java.header"/>
<property key="checkstyle.suppressions.file"
file="docs/suppressions.xml"/>
</checkstyle>
<mkdir dir="target/style/frames"/>
<mkdir dir="target/style/noframes"/>
<mkdir dir="target/style/simple"/>
<mkdir dir="target/style/csv"/>
<style basedir="target"
destdir="target/style/noframes"
includes="cs_errors.xml"
style="contrib/checkstyle-noframes.xsl"/>
<style basedir="target"
destdir="target/style/frames"
includes="cs_errors.xml"
style="contrib/checkstyle-frames.xsl"/>
<style basedir="target"
destdir="target/style/simple"
includes="cs_errors.xml"
style="contrib/checkstyle-simple.xsl"/>
<style out="target/style/csv/report-csv.txt"
in="target/cs_errors.xml"
style="contrib/checkstyle-csv.xsl"/>
</target>
<!-- Targets to verify that JUnit is in the classpath -->
<target name="check.junit"
description="Checks whether JUnit is in the classpath">
<available property="have.junit"
classname="junit.framework.TestListener"/>
</target>
<target name="require.junit" depends="check.junit" unless="have.junit"
description="Fails if JUnit is not present in the classpath">
<fail message="Need to have JUnit in your CLASSPATH to run the tests. Consider using the one in the lib directory."/>
</target>
<!-- Targets to verify that Xalan is in the classpath -->
<target name="check.xalan"
description="Checks whether xalan is in the classpath">
<condition property="have.xalan">
<or>
<!-- jdk 1.3 with modern Xalan -->
<available classname="org.apache.xalan.Version"/>
<!-- Xalan classes in jdk 1.4 (beta 3) are OK for running -->
<!-- the tests, but there is no Version class in jdk 1.4: -->
<!-- fallback to stable jaxp implementation class -->
<available classname="org.apache.xalan.transformer.TransformerImpl"/>
</or>
</condition>
</target>
<target name="require.xalan" depends="check.xalan" unless="have.xalan"
description="Fails if xalan is not present in the classpath">
<fail message="Need to have Xalan in your CLASSPATH to run the tests. You can download it from http://xml.apache.org/."/>
</target>
<!-- To run the tests need Xalan in the classpath -->
<target name="run.tests"
depends="compile.tests,require.ant15,require.junit,require.xalan"
description="Runs the tests for checkstyle">
<mkdir dir="${testreport.dir}"/>
<property name="testinputs.dir"
location="src/testinputs/com/puppycrawl/tools/checkstyle"/>
<property name="testcases" value="**/*Test.java"/>
<junit printsummary="yes"
fork="yes"
haltonfailure="no"
showoutput="yes"
failureProperty="tests.have.failed">
<jvmarg value="-Dtestinputs.dir=${testinputs.dir}"/>
<formatter type="xml" />
<classpath refid="tests.runpath"/>
<batchtest todir="${testreport.dir}">
<fileset dir="src/tests">
<include name="${testcases}" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${testreport.dir}">
<fileset dir="${testreport.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${testreport.dir}"/>
</junitreport>
<property name="report"
value="${basedir}/${testreport.dir}/index.html"/>
<fail if="tests.have.failed"
message="Unit tests failed - Report is available in ${report}"/>
</target>
<!-- To run the tests need Xalan in the classpath -->
<target name="run.test.suite"
depends="compile.tests,require.ant15,require.junit,require.xalan"
description="Runs the tests for checkstyle as a test suite">
<mkdir dir="${testreport.dir}"/>
<property name="testinputs.dir"
location="src/testinputs/com/puppycrawl/tools/checkstyle"/>
<property name="testcases"
value="com/puppycrawl/tools/checkstyle/AllTests.java"/>
<junit printsummary="yes"
fork="yes"
haltonfailure="no"
showoutput="yes"
failureProperty="tests.have.failed">
<jvmarg value="-Dtestinputs.dir=${testinputs.dir}"/>
<formatter type="xml" />
<classpath refid="tests.runpath"/>
<batchtest todir="${testreport.dir}">
<fileset dir="src/tests">
<include name="${testcases}" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${testreport.dir}">
<fileset dir="${testreport.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${testreport.dir}"/>
</junitreport>
<property name="report"
value="${basedir}/${testreport.dir}/index.html"/>
<fail if="tests.have.failed"
message="Unit tests failed - Report is available in ${report}"/>
</target>
<!-- -->
<!-- DIST TARGETS -->
<!-- -->
<target name="build.bindist" depends="compile.checkstyle, javadoc, xdocs"
description="Builds the compressed distribution files">
<delete dir="${dist.dir}/checkstyle-${version}" />
<mkdir dir="${dist.dir}/checkstyle-${version}" />
<jar jarfile="${dist.dir}/checkstyle-${version}/checkstyle-${version}.jar"
basedir="target/checkstyle"
excludes="**/usage/**, **/j2ee/**"
manifest="config/manifest.mf" />
<jar jarfile="${dist.dir}/checkstyle-${version}/checkstyle-optional-${version}.jar"
basedir="target/checkstyle"
includes="**/usage/**, **/j2ee/**"/>
<!-- copy the JARS and make a mega JAR out of them -->
<copy file="${regexp.jar}" todir="${dist.dir}/checkstyle-${version}" />
<copy file="${antlr.jar}" todir="${dist.dir}/checkstyle-${version}" />
<copy file="${beanutils.jar}" todir="${dist.dir}/checkstyle-${version}" />
<copy file="${collections.jar}" todir="${dist.dir}/checkstyle-${version}" />
<copy file="${cli.jar}" todir="${dist.dir}/checkstyle-${version}" />
<copy file="${logging.jar}" todir="${dist.dir}/checkstyle-${version}" />
<mkdir dir="${dist.dir}/checkstyle-${version}/tmp" />
<unjar src="${dist.dir}/checkstyle-${version}/antlr.jar"
dest="${dist.dir}/checkstyle-${version}/tmp" />
<unjar src="${dist.dir}/checkstyle-${version}/jakarta-regexp-1.3.jar"
dest="${dist.dir}/checkstyle-${version}/tmp" />
<unjar src="${dist.dir}/checkstyle-${version}/commons-beanutils.jar"
dest="${dist.dir}/checkstyle-${version}/tmp" />
<unjar src="${dist.dir}/checkstyle-${version}/commons-collections.jar"
dest="${dist.dir}/checkstyle-${version}/tmp" />
<unjar src="${dist.dir}/checkstyle-${version}/commons-cli.jar"
dest="${dist.dir}/checkstyle-${version}/tmp" />
<unjar src="${dist.dir}/checkstyle-${version}/commons-logging.jar"
dest="${dist.dir}/checkstyle-${version}/tmp" />
<unjar src="${dist.dir}/checkstyle-${version}/checkstyle-${version}.jar"
dest="${dist.dir}/checkstyle-${version}/tmp" />
<delete dir="${dist.dir}/checkstyle-${version}/tmp/META-INF" />
<jar jarfile="${dist.dir}/checkstyle-${version}/checkstyle-all-${version}.jar"
basedir="${dist.dir}/checkstyle-${version}/tmp"
manifest="config/manifest.mf" />
<delete dir="${dist.dir}/checkstyle-${version}/tmp" />
<!-- copy stuff without filtering -->
<copy todir="${dist.dir}/checkstyle-${version}">
<fileset dir=".">
<include name="LICENSE*"/>
<include name="README"/>
<include name="RIGHTS.antlr"/>
<include name="TODO"/>
<include name="contrib/**"/>
<include name="**/.cvsignore"/>
<include name="**/CVS"/>
<include name="docs/**"/>
<exclude name="docs/*.html"/>
</fileset>
</copy>
<!-- copy stuff with filtering -->
<copy todir="${dist.dir}/checkstyle-${version}">
<fileset dir=".">
<include name="docs/*.html"/>
</fileset>
<filterset>
<filter token="CHECKSTYLE_VERSION" value="${version}" />
</filterset>
</copy>
<!-- create the final zip & tar/gzip files -->
<zip zipfile="${dist.dir}/checkstyle-${version}.zip">
<fileset dir="${dist.dir}">
<include name="checkstyle-${version}/**"/>
</fileset>
</zip>
<tar tarfile="${dist.dir}/checkstyle-${version}.tar" longfile="gnu"
basedir="${dist.dir}" includes="checkstyle-${version}/**" />
<gzip zipfile="${dist.dir}/checkstyle-${version}.tar.gz"
src="${dist.dir}/checkstyle-${version}.tar" />
</target>
<target name="build.srcdist" depends="checkstyle.checkstyle"
description="Builds the compressed source files for distribution">
<delete dir="${dist.dir}/checkstyle-src-${version}" />
<mkdir dir="${dist.dir}/checkstyle-src-${version}" />
<copy todir="${dist.dir}/checkstyle-src-${version}">
<fileset dir=".">
<exclude name="src/checkstyle/**/Generated*.java"/>
<exclude name="src/checkstyle/**/Generated*.txt"/>
<include name="LICENSE*"/>
<include name="README"/>
<include name="RIGHTS.antlr"/>
<include name="TODO"/>
<include name="build.xml"/>
<include name="config/**"/>
<include name="contrib/**"/>
<include name="docs/*"/>
<include name="lib/**"/>
<include name="src/**"/>
</fileset>
</copy>
<!-- Produce the final distributions -->
<zip zipfile="${dist.dir}/checkstyle-src-${version}.zip">
<fileset dir="${dist.dir}">
<include name="checkstyle-src-${version}/**"/>
</fileset>
</zip>
<tar tarfile="${dist.dir}/checkstyle-src-${version}.tar" longfile="gnu"
basedir="${dist.dir}" includes="checkstyle-src-${version}/**" />
<gzip zipfile="${dist.dir}/checkstyle-src-${version}.tar.gz"
src="${dist.dir}/checkstyle-src-${version}.tar" />
</target>
<!-- -->
<!-- DOC TARGETS -->
<!-- -->
<target name="javadoc" depends="compile.checkstyle"
description="Creates the javadoc html files">
<mkdir dir="${xdocs.dest}/api" />
<javadoc sourcepath="src/checkstyle" destdir="${xdocs.dest}/api"
Windowtitle="Checkstyle API"
classpathref="javadoc.classpath"
Use="true"
Footer="&lt;a target=&quot;_top&quot; href=&quot;./{@docRoot}/../index.html&quot;&gt;Back to the Checkstyle Home Page&lt;/a&gt;"
failonerror="yes" >
<fileset dir="src/checkstyle">
<exclude name="**/Generated*.java" />
<exclude name="**/Generated*.txt" />
<exclude name="**/gui/*.java" />
<exclude name="**/usage/transmogrify/*.java" />
<exclude name="**/*.properties" />
<exclude name="**/*.g" />
<exclude name="**/*.dtd" />
<exclude name="**/*.xml" />
<exclude name="**/*.html" />
</fileset>
</javadoc>
</target>
<target name="xdocs" depends="compile.checkstyle">
<mkdir dir="${xdocs.dest}"/>
<mkdir dir="target/xdocs"/>
<copy todir="target/xdocs">
<fileset dir="${xdocs.src}">
<exclude name="**/*.png"/>
<exclude name="**/*.css"/>
</fileset>
</copy>
<javadoc
sourcepath="src/checkstyle" destdir="target/xdocs"
classpathref="javadoc.classpath"
failonerror="yes">
<doclet name="com.puppycrawl.tools.checkstyle.doclets.CheckDocsDoclet"
path="target/checkstyle">
</doclet>
<packageset dir="src/checkstyle">
<include name="**/checks/**" />
<include name="**/checks" />
</packageset>
</javadoc>
<taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask">
<classpath refid="velocity.classpath"/>
</taskdef>
<copy todir="${xdocs.dest}">
<fileset dir="${xdocs.src}">
<include name="**/*.png"/>
<include name="**/*.css"/>
</fileset>
</copy>
<anakia basedir="target/xdocs" destdir="${xdocs.dest}/"
extension=".html"
style="site.vsl"
projectFile="stylesheets/project.xml"
excludes="**/stylesheets/**"
includes="**/*.xml"
lastModifiedCheck="true"
templatePath="src/xdocs/stylesheets">
</anakia>
</target>
<!-- Added for GUMP testing -->
<target name="gump.setup" description="Sets up any properties">
<property name="translation.severity" value="ignore"/>
</target>
<target name="gump" depends="gump.setup,build.bindist,build.srcdist,run.test.suite"
description="Runs the test for GUMP testing"/>
<!-- Added for Clover testing -->
<property name="clover.excludes"
value="**/CheckStyleTas*,**/Generated*.java,**/Java*Recognizer.java,**/Java*Lexer.java,**/Java*TokenTypes.java,**/gui/*"/>
<target name="with.clover">
<taskdef resource="clovertasks"/>
<mkdir dir="target/clover/db"/>
<mkdir dir="target/clover/html"/>
<clover-setup initString="target/clover/db/csdb"/>
<property name="clover.html.dir" location="target/clover/html"/>
</target>
<target name="clover.report" depends="with.clover">
<clover-report>
<current outfile="${clover.html.dir}" title="Checkstyle Project">
<format type="html"/>
</current>
</clover-report>
</target>
<target name="clover.viewer" depends="with.clover">
<clover-view/>
</target>
<!-- Targets to verify that Xerces is in the classpath -->
<target name="check.xerces"
description="Checks whether xerces is in the classpath">
<condition property="have.xerces">
<available classname="org.apache.xerces.parsers.SAXParser"/>
</condition>
</target>
<target name="require.xerces" depends="check.xerces" unless="have.xerces"
description="Fails if xerces is not present in the classpath">
<fail message="Need to have Xerces-J in your CLASSPATH to run the tests. You can download it from http://xml.apache.org/."/>
</target>
<target name="validate.xml"
depends="require.xerces"
description="Validates checkstyle XML file">
<xmlvalidate file="docs/checkstyle_checks.xml">
<xmlcatalog>
<dtd
publicId="-//Puppy Crawl//DTD Check Configuration 1.1//EN"
location="${checkstyle.dir}/configuration_1_1.dtd"/>
</xmlcatalog>
</xmlvalidate>
</target>
<!-- Targets to verify that ANT version if at least 1.5 -->
<target name="check.ant15">
<echo>version is ${ant.version}</echo>
<condition property="have.ant15">
<not>
<or>
<equals arg1="${ant.version}"
arg2="Ant version 1.4.1 compiled on October 11 2001"/>
</or>
</not>
</condition>
</target>
<target name="require.ant15" depends="check.ant15" unless="have.ant15">
<fail message="Need at least version 1.5 of ANT - you have ${ant.version}"/>
</target>
<target name="checkstyle.run" depends="compile.checkstyle"
description="Runs checkstyle.">
<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
<classpath refid="run.classpath"/>
</taskdef>
<delete file="target/cachefile" />
<property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
<property name="check.config" location="docs/checkstyle_checks.xml"/>
<property name="translation.severity" value="error"/>
<checkstyle config="${custom.config}" file="${file.to.check}">
<formatter type="plain"/>
<formatter type="xml" toFile="target/cs_errors.xml"/>
<classpath refid="run.classpath"/>
</checkstyle>
</target>
</project>