481 lines
18 KiB
XML
481 lines
18 KiB
XML
<project name="test" 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="antlr.jar" value="lib/antlr.jar" />
|
|
<property name="antlr-tools.jar" value="lib/antlr-tools.jar" />
|
|
<property name="regexp.jar" value="lib/jakarta-regexp-1.2.jar" />
|
|
<property name="bcel.jar" value="lib/bcel.jar" />
|
|
<property name="junit.jar" value="lib/junit.jar" />
|
|
|
|
<property name="checkstyle.dir"
|
|
value="src/checkstyle/com/puppycrawl/tools/checkstyle" />
|
|
<property name="testreport.dir" value="target/testreports"/>
|
|
<property name="dist.dir" value="target/dist"/>
|
|
|
|
<property name="version" value="2.4beta" />
|
|
|
|
<path id="build.classpath">
|
|
<pathelement location="${antlr.jar}" />
|
|
<pathelement location="${regexp.jar}" />
|
|
<pathelement location="${bcel.jar}" />
|
|
<pathelement location="${ant.home}/lib/ant.jar" />
|
|
</path>
|
|
|
|
<path id="run.classpath">
|
|
<pathelement location="target/checkstyle" />
|
|
<path refid="build.classpath" />
|
|
</path>
|
|
|
|
<!-- add classes to generate Javadoc -->
|
|
<path id="javadoc.classpath">
|
|
<pathelement location="${ant.home}/lib/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" />
|
|
<path refid="tests.buildpath" />
|
|
</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"/>
|
|
</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.dir}/GeneratedJava14Lexer.java" >
|
|
<srcfiles dir= "${checkstyle.dir}" includes="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-tools.jar}"
|
|
fork="yes"
|
|
dir="${checkstyle.dir}">
|
|
<arg value="java.g" />
|
|
</java>
|
|
<java classname="antlr.Tool"
|
|
classpath="${antlr-tools.jar}"
|
|
fork="yes"
|
|
dir="${checkstyle.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" />
|
|
<native2ascii src="src/checkstyle"
|
|
dest="target/checkstyle"
|
|
encoding="EUC-JP"
|
|
includes="**/*_ja.properties" />
|
|
<copy todir="target/checkstyle">
|
|
<fileset dir="src/checkstyle" includes="**/*.properties"/>
|
|
</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>
|
|
|
|
|
|
</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}"/>
|
|
</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">
|
|
<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" />
|
|
</target>
|
|
|
|
<!-- -->
|
|
<!-- TEST TARGETS -->
|
|
<!-- -->
|
|
|
|
<!-- 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="src/tests/com/puppycrawl/tools/checkstyle"
|
|
classpathref="run.classpath">
|
|
<sysproperty key="checkstyle.allow.tabs" value="yes"/>
|
|
<arg value="InputSimple.java" />
|
|
</java>
|
|
<java classname="com.puppycrawl.tools.checkstyle.Main"
|
|
fork="yes"
|
|
dir="."
|
|
classpathref="run.classpath">
|
|
<arg value="-r"/>
|
|
<arg value="src"/>
|
|
</java>
|
|
</target>
|
|
|
|
<target name="checkstyle.simple" depends="compile.tests"
|
|
description="Runs checkstyle on a file to test white spaces">
|
|
<taskdef resource="checkstyletask.properties">
|
|
<classpath refid="run.classpath"/>
|
|
</taskdef>
|
|
<checkstyle file="src/tests/com/puppycrawl/tools/checkstyle/InputWhitespace.java"/>
|
|
</target>
|
|
|
|
<target name="checkstyle.import" depends="compile.tests"
|
|
description="Runs checkstyle on a file to test imports">
|
|
<taskdef name="checkstyle"
|
|
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
|
|
<classpath refid="run.classpath"/>
|
|
</taskdef>
|
|
<echo message="Expect to get a message after checkstyle"/>
|
|
<checkstyle failOnViolation="false"
|
|
file="src/tests/com/puppycrawl/tools/checkstyle/InputImport.java" />
|
|
<echo message="THIS IS THE EXPECTED MESSAGE"/>
|
|
</target>
|
|
|
|
<target name="checkstyle.checkstyle" depends="compile.checkstyle"
|
|
description="Runs checkstyle on a file to test various rules">
|
|
<taskdef name="checkstyle"
|
|
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
|
|
<classpath refid="run.classpath"/>
|
|
</taskdef>
|
|
<delete file="target/cachefile" />
|
|
<checkstyle properties="docs/checkstyle.rules">
|
|
<fileset dir="src/checkstyle"
|
|
includes="**/*.java"
|
|
excludes="**/Generated*.java"/>
|
|
<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"/>
|
|
</checkstyle>
|
|
</target>
|
|
|
|
<target name="checkstyle.noargs" depends="compile.checkstyle"
|
|
description="Runs checkstyle with no arguments">
|
|
<taskdef name="checkstyle"
|
|
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
|
|
<classpath refid="run.classpath"/>
|
|
</taskdef>
|
|
<echo message="Calling checkstyle with no arguments" />
|
|
<checkstyle/>
|
|
</target>
|
|
|
|
<target name="checkstyle.another" depends="compile.checkstyle"
|
|
description="Runs checkstyle with missing properties file">
|
|
<taskdef name="checkstyle"
|
|
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
|
|
<classpath refid="run.classpath"/>
|
|
</taskdef>
|
|
<echo message="Calling checkstyle with missing properties file" />
|
|
<checkstyle properties="xzzaaqqwet3ad"/>
|
|
</target>
|
|
|
|
<target name="checkstyle.style" depends="compile.checkstyle"
|
|
description="Runs checkstyle to test generation of error reports">
|
|
<taskdef name="checkstyle"
|
|
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
|
|
<classpath refid="run.classpath"/>
|
|
</taskdef>
|
|
<mkdir dir="target/style/frames"/>
|
|
<mkdir dir="target/style/noframes"/>
|
|
<mkdir dir="target/style/simple"/>
|
|
<checkstyle failOnViolation="false"
|
|
basedir=".">
|
|
<fileset dir="src/checkstyle"
|
|
includes="**/*.java"
|
|
excludes="**/Generated*.java"/>
|
|
<formatter type="xml" toFile="target/style/cs_errors.xml"/>
|
|
<classpath refid="build.classpath"/>
|
|
</checkstyle>
|
|
<style basedir="target/style"
|
|
destdir="target/style/noframes"
|
|
includes="cs_errors.xml"
|
|
style="contrib/checkstyle-noframes.xsl"/>
|
|
<style basedir="target/style"
|
|
destdir="target/style/frames"
|
|
includes="cs_errors.xml"
|
|
style="contrib/checkstyle-frames.xsl"/>
|
|
<style basedir="target/style"
|
|
destdir="target/style/simple"
|
|
includes="cs_errors.xml"
|
|
style="contrib/checkstyle-simple.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.junit,require.xalan"
|
|
description="Runs the tests for checkstyle">
|
|
|
|
<mkdir dir="${testreport.dir}"/>
|
|
<property name="testinputs.dir"
|
|
location="src/testinputs/com/puppycrawl/tools/checkstyle"/>
|
|
|
|
<junit printsummary="yes"
|
|
fork="yes"
|
|
haltonfailure="no"
|
|
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="**/*Test.java" />
|
|
</fileset>
|
|
</batchtest>
|
|
</junit>
|
|
|
|
<junitreport todir="${testreport.dir}">
|
|
<fileset dir="${testreport.dir}">
|
|
<include name="TEST-*.xml"/>
|
|
</fileset>
|
|
<report todir="${testreport.dir}"/>
|
|
</junitreport>
|
|
|
|
<!-- if only fail had an if attribute ... ugly workaround follows -->
|
|
<antcall target="check.tests.failed"/>
|
|
|
|
</target>
|
|
|
|
<target name="check.tests.failed" if="tests.have.failed"
|
|
description="Fails if the unit tests have failed">
|
|
<property name="report"
|
|
value="${basedir}/${testreport.dir}/index.html"/>
|
|
<fail message="Unit tests failed - Report is available in ${report}"/>
|
|
</target>
|
|
|
|
<target name="jdepend">
|
|
<mkdir dir="target/jdep"/>
|
|
<jdepend format="xml" outputfile="target/jdep/jdepend-report.xml">
|
|
<sourcespath>
|
|
<pathelement location="src/checkstyle" />
|
|
</sourcespath>
|
|
<classpath location="C:/apps/jdepend-2.2/lib/jdepend.jar" />
|
|
</jdepend>
|
|
|
|
<style basedir="target/jdep" destdir="target/jdep"
|
|
includes="jdepend-report.xml" style="jdepend.xsl" />
|
|
</target>
|
|
|
|
<!-- -->
|
|
<!-- DIST TARGETS -->
|
|
<!-- -->
|
|
<target name="build.bindist" depends="compile.checkstyle, javadoc"
|
|
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"
|
|
manifest="config/manifest.mf" />
|
|
<!-- 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}" />
|
|
<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.2.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"
|
|
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"
|
|
basedir="${dist.dir}" includes="checkstyle-src-${version}/**" />
|
|
<gzip zipfile="${dist.dir}/checkstyle-src-${version}.tar.gz"
|
|
src="${dist.dir}/checkstyle-src-${version}.tar" />
|
|
</target>
|
|
|
|
<target name="javadoc" depends="compile.checkstyle"
|
|
description="Creates the javadoc html files">
|
|
<mkdir dir="docs/api" />
|
|
<move toDir="src/checkstyle">
|
|
<fileset dir="src/checkstyle" includes="**/Generated*.java" />
|
|
<fileset dir="src/checkstyle" includes="**/Generated*.txt" />
|
|
<fileset dir="src/checkstyle" includes="**/MyCommonAST.java" />
|
|
<mapper type="glob" from="*" to="*.HIDING"/>
|
|
</move>
|
|
<javadoc sourcepath="src/checkstyle" destdir="docs/api"
|
|
packagenames="com.puppycrawl.tools.checkstyle"
|
|
Windowtitle="Checkstyle API"
|
|
classpathref="javadoc.classpath" />
|
|
<move toDir="src/checkstyle">
|
|
<fileset dir="src/checkstyle" includes="**/*.HIDING" />
|
|
<mapper type="glob" from="*.HIDING" to="*"/>
|
|
</move>
|
|
</target>
|
|
|
|
<!-- Added for GUMP testing -->
|
|
<target name="gump" depends="build.bindist,build.srcdist,run.tests"
|
|
description="Runs the test for GUMP testing"/>
|
|
</project>
|