423 lines
15 KiB
XML
423 lines
15 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="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.3beta" />
|
|
|
|
<path id="build.classpath">
|
|
<pathelement location="${antlr.jar}" />
|
|
<pathelement location="${regexp.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/ant.jar" />
|
|
<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">
|
|
<property name="asd" refid="run.classpath" />
|
|
<echo message="Classpath is ${asd}" />
|
|
</target>
|
|
|
|
<!-- -->
|
|
<!-- Cleanup targets -->
|
|
<!-- -->
|
|
<target name="clean">
|
|
<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">
|
|
<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">
|
|
<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">
|
|
<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" />
|
|
<copy file="src/checkstyle/checkstyletask.properties"
|
|
todir="target/checkstyle"/>
|
|
</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">
|
|
<mkdir dir="target/tests" />
|
|
<depend srcdir="src/tests" destdir="target/tests" 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/tests"
|
|
destdir="target/tests"
|
|
deprecation="on" debug="on"
|
|
excludes="${testExcludes}"
|
|
classpathref="tests.buildpath" />
|
|
</target>
|
|
|
|
<!-- -->
|
|
<!-- TEST TARGETS -->
|
|
<!-- -->
|
|
|
|
<!-- runs the command line version on a file -->
|
|
<target name="run.checkstyle" depends="compile.tests">
|
|
<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">
|
|
<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">
|
|
<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">
|
|
<taskdef name="checkstyle"
|
|
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
|
|
<classpath refid="run.classpath"/>
|
|
</taskdef>
|
|
<delete file="target/cachefile" />
|
|
<checkstyle headerfile="docs/java.header"
|
|
ignorebraces="false"
|
|
cachefile="target/cachefile"
|
|
memberPattern="^m[A-Z][a-zA-Z0-9]*$"
|
|
staticPattern="^s[A-Z][a-zA-Z0-9]*$"
|
|
paramPattern="^a[A-Z][a-zA-Z0-9]*$"
|
|
lcurlyMethod="nl"
|
|
lcurlyOther="nlow"
|
|
lcurlyType="nl"
|
|
rcurly="alone"
|
|
parenPad="nospace"
|
|
catchBlock="text"
|
|
checkUnusedThrows="true"
|
|
todoPattern="TODO:">
|
|
<fileset dir="src/checkstyle"
|
|
includes="**/*.java"
|
|
excludes="**/Generated*.java"/>
|
|
<formatter type="plain"/>
|
|
<formatter type="xml" toFile="target/cs_errors.xml"/>
|
|
<classpath refid="build.classpath"/>
|
|
</checkstyle>
|
|
</target>
|
|
|
|
<target name="checkstyle.noargs" depends="compile.checkstyle">
|
|
<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">
|
|
<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">
|
|
<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">
|
|
<available property="have.junit"
|
|
classname="junit.framework.TestListener"/>
|
|
</target>
|
|
<target name="require.junit" depends="check.junit" unless="have.junit">
|
|
<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">
|
|
<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">
|
|
<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">
|
|
|
|
<mkdir dir="${testreport.dir}"/>
|
|
<property name="tests.dir"
|
|
location="src/tests/com/puppycrawl/tools/checkstyle"/>
|
|
|
|
<junit printsummary="yes"
|
|
fork="yes"
|
|
haltonfailure="no"
|
|
failureProperty="tests.have.failed">
|
|
<jvmarg value="-Dtests.dir=${tests.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">
|
|
<property name="report"
|
|
value="${basedir}/${testreport.dir}/index.html"/>
|
|
<fail message="Unit tests failed - Report is available in ${report}"/>
|
|
</target>
|
|
|
|
<!-- -->
|
|
<!-- DIST TARGETS -->
|
|
<!-- -->
|
|
<target name="build.bindist" depends="compile.checkstyle, javadoc">
|
|
<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 documentation -->
|
|
<copy todir="${dist.dir}/checkstyle-${version}">
|
|
<fileset dir=".">
|
|
<include name="LICENSE*"/>
|
|
<include name="README"/>
|
|
<include name="RIGHTS.antlr"/>
|
|
<include name="TODO"/>
|
|
<include name="docs/**"/>
|
|
<include name="contrib/**"/>
|
|
<include name="**/.cvsignore"/>
|
|
<include name="**/CVS"/>
|
|
</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">
|
|
<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">
|
|
<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"/>
|
|
</project>
|