Parent Directory
|
Revision Log
Allow configuring compiler for 1.3, 2.0-variance, and 2.0-novariance.
<project name="jsr166" default="usage">
<description>
------------------------------------------------------------------------------
Build file for JSR-166
Usage: ant [target]
User-specific settings are read from user.properties.
See user.properties.sample for an explanation of some useful settings.
------------------------------------------------------------------------------
</description>
<target name="usage" description="Advises user to run with -projecthelp">
<echo>Run "ant -projecthelp" for full usage information.</echo>
</target>
<!-- User-specific settings -->
<property file="user.properties"/>
<!-- Compilation options -->
<property name="build.sourcelevel" value="1.5"/>
<property name="build.docsourcelevel" value="1.4"/>
<property name="build.debug" value="true"/>
<property name="build.debuglevel" value="source,lines,vars"/>
<property name="build.deprecation" value="false"/>
<!-- Build locations -->
<property name="build.dir" location="build"/>
<property name="build.classes.dir" location="${build.dir}/classes"/>
<property name="build.emulation.dir" location="${build.dir}/emulation"/>
<property name="build.testcases.dir" location="${build.dir}/testcases"/>
<property name="build.lib.dir" location="${build.dir}/lib"/>
<property name="build.ant.dir" location="${build.dir}/ant"/>
<property name="build.javadocs.dir" location="${build.dir}/javadocs"/>
<property name="build.stripped.dir" location="${build.dir}/stripped"/>
<property name="build.reports.dir" location="${build.dir}/reports"/>
<property name="build.doccheck.dir" location="${build.dir}/doccheck"/>
<property name="build.filter.src.dir" location="${build.dir}/filtersrc"/>
<!-- Source locations -->
<property name="src.dir" location="${basedir}/src/main"/>
<property name="emulation.src.dir" location="${basedir}/src/emulation"/>
<property name="test.src.dir" location="${basedir}/src/test"/>
<property name="ant.src.dir" location="${basedir}/etc/ant"/>
<property name="stylesheet.dir" location="${basedir}/etc/xsl"/>
<property name="lib.dir" location="${basedir}/lib"/>
<property name="dist.dir" location="${basedir}/dist"/>
<!-- Distribution locations -->
<property name="dist.javadocs.dir" location="${dist.dir}/docs"/>
<!-- Jar locations -->
<property name="product.jar" location="${build.lib.dir}/jsr166.jar"/>
<property name="junit.jar" location="${lib.dir}/junit.jar"/>
<property name="rt.jar" location="${java.home}/lib/rt.jar"/>
<!-- Files excluded from emulation and dist-docs -->
<patternset id="emulation.excludes">
<exclude name="java/util/Random.*"/>
<exclude name="sun/misc/Unsafe.*"/>
</patternset>
<!-- Main targets -->
<target name="compile"
depends="init, configure-compiler"
description="Compiles main sources to build folder">
<mkdir dir="${build.classes.dir}"/>
<javac srcdir="${src.dir}"
destdir="${build.classes.dir}"
debug="${build.debug}"
debuglevel="${build.debuglevel}"
deprecation="${build.deprecation}"
source="${build.sourcelevel}"
fork="true">
<bootclasspath refid="javac.bootclasspath"/>
<compilerarg line="${build.javac.args}"/>
</javac>
</target>
<target name="jar"
depends="configure-emulation, init-jar, native-jar, emulation-jar"
description="Builds library jar from compiled sources"/>
<target name="test"
depends="init, configure-tests, report-tests"
description="Runs all tests (requires JUnit 3.8.1 in ${ant.home}/lib)" />
<target name="checkstyle"
depends="filter-src"
description="Reports on style errors in Java source (verbose, mostly chaff)">
<taskdef resource="checkstyletask.properties"
classpath="${lib.dir}/checkstyle-all-2.4.jar"/>
<checkstyle>
<formatter type="plain"/> <!-- also available: type="xml" -->
<fileset dir="${build.filter.src.dir}" includes="**/*.java"/>
</checkstyle>
</target>
<target name="doccheck"
depends="filter-src"
description="Reports on javadoc style errors (not working yet)">
<delete dir="${build.doccheck.dir}"/>
<mkdir dir="${build.doccheck.dir}"/>
<javadoc doclet="com.sun.tools.doclets.doccheck.DocCheck"
docletpath="${lib.dir}/doccheck.jar"
destdir="${build.doccheck.dir}">
<packageset dir="${build.filter.src.dir}"/>
</javadoc>
</target>
<target name="docs"
depends="filter-src"
description="Builds javadocs with custom tags to build folder">
<delete dir="${build.javadocs.dir}"/>
<mkdir dir="${build.javadocs.dir}"/>
<javadoc destdir="${build.javadocs.dir}"
link="http://java.sun.com/j2se/1.4.1/docs/api"
overview="${src.dir}/intro.html"
source="${build.docsourcelevel}">
<tag name="revised" description="Last revised:"/>
<tag name="spec" description="Specified by:"/>
<tag name="editor" description="Last edited by:"/>
<tag name="fixme" description="FIX ME:"/>
<packageset dir="${build.filter.src.dir}"/>
</javadoc>
</target>
<target name="strip"
depends="init, configure-compiler"
description="Strip generics from java source (not working yet)">
<mkdir dir="${build.stripped.dir}"/>
<!--
# javac -s doesn't reliably generate compilable code. It generates
# bridge methods (marked as "synthetic") that can have identical
# signatures to existing methods except for the return value.
-->
<javac srcdir="${src.dir}"
destdir="${build.stripped.dir}"
debug="${build.debug}"
debuglevel="${build.debuglevel}"
deprecation="${build.deprecation}"
source="${build.sourcelevel}"
fork="true">
<bootclasspath refid="javac.bootclasspath"/>
<compilerarg line="${build.javac.args} -s"/>
</javac>
</target>
<target name="dist"
depends="init, dist-clean, dist-jar, dist-docs"
description="Puts all distributable products in single hierarchy"/>
<target name="clean"
description="Removes all build products">
<delete dir="${build.dir}"/>
<delete dir="${build.classes.dir}"/>
<delete dir="${build.lib.dir}"/>
</target>
<target name="dist-clean"
description="Removes all build and distribution products">
<delete dir="${dist.dir}"/>
</target>
<target name="dist-docs"
depends="filter-src"
description="Builds javadocs without custom tags to dist folder">
<delete dir="${dist.javadocs.dir}"/>
<mkdir dir="${dist.javadocs.dir}"/>
<javadoc destdir="${dist.javadocs.dir}"
link="http://java.sun.com/j2se/1.4.1/docs/api"
overview="${src.dir}/intro.html"
source="${build.docsourcelevel}">
<packageset dir="${build.filter.src.dir}"/>
</javadoc>
</target>
<!-- Internal targets -->
<target name="init">
<!-- Version is kept in a separate file -->
<loadfile property="version" srcFile="version.properties"/>
<echo>Building JSR-166 version ${version}</echo>
</target>
<target name="init-jar">
<mkdir dir="${build.lib.dir}"/>
</target>
<target name="native-jar"
depends="compile"
unless="build.emulation.true">
<jar destfile="${product.jar}">
<fileset dir="${build.classes.dir}"/>
</jar>
</target>
<target name="compile-emulation"
depends="init, configure-compiler"
if="build.emulation.true">
<mkdir dir="${build.emulation.dir}"/>
<javac srcdir="${emulation.src.dir}"
destdir="${build.emulation.dir}"
debug="${build.debug}"
debuglevel="${build.debuglevel}"
deprecation="${build.deprecation}"
source="${build.sourcelevel}"
fork="true">
<bootclasspath refid="javac.bootclasspath"/>
<compilerarg line="${build.javac.args}"/>
</javac>
</target>
<target name="emulation-jar"
depends="compile-emulation"
if="build.emulation.true">
<jar destfile="${product.jar}" duplicate="add">
<fileset dir="${build.classes.dir}">
<patternset refid="emulation.excludes"/>
</fileset>
<fileset dir="${build.emulation.dir}"/>
</jar>
</target>
<target name="dist-jar"
depends="clean, jar">
<copy file="${product.jar}" todir="${dist.dir}"/>
</target>
<target name="compile-ant-filter"
depends="init">
<mkdir dir="${build.ant.dir}"/>
<javac srcdir="${ant.src.dir}"
destdir="${build.ant.dir}"
source="1.4"
/>
</target>
<target name="filter-src"
depends="compile-ant-filter">
<mkdir dir="${build.filter.src.dir}"/>
<copy todir="${build.filter.src.dir}">
<fileset dir="${src.dir}">
<include name="**/*.html"/>
</fileset>
</copy>
<copy todir="${build.filter.src.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.html"/>
<patternset refid="emulation.excludes"/>
</fileset>
<filterchain>
<filterreader classname="jsr166.ant.filters.ReplaceFilter"
classpath="${build.ant.dir}">
<!--
# These arguments are to get rid of angle-bracketed type
# parameters so that javadoc can run on the result. The
# following heuristic that seems to work:
#
# For all lines not starting with space(s)-asterisk-space(s),
# replace <something> with a space, where there may be more
# than one right angle bracket at the end, and "something"
# must not contain parens or pipes. (This may need some
# tweaking.)
-->
<param name="notmatching" value="^\s+\*\s.*$"/>
<param name="pattern" value="<[^|>()]+?>+"/>
<param name="replacement" value=" "/>
</filterreader>
<filterreader classname="jsr166.ant.filters.ReplaceFilter"
classpath="${build.ant.dir}">
<!--
# These arguments are to uncomment lines beginning with
# "//@" so that javadoc can see imports that are needed
# to resolve links but that shouldn't be in the compiled
# code.
-->
<param name="matching" value="^//@.*$"/>
<param name="pattern" value="^//@"/>
<param name="replacement" value=""/>
</filterreader>
</filterchain>
</copy>
</target>
<target name="compile-tests"
depends="jar">
<mkdir dir="${build.testcases.dir}"/>
<javac srcdir="${test.src.dir}"
destdir="${build.testcases.dir}"
debug="${build.debug}"
debuglevel="${build.debuglevel}"
deprecation="${build.deprecation}"
source="${build.sourcelevel}"
fork="true">
<classpath refid="test.classpath"/>
<bootclasspath refid="javac.bootclasspath"/>
<compilerarg line="${build.javac.args}"/>
</javac>
</target>
<target name="run-tests"
depends="compile-tests">
<!-- May be overridden by user.properties -->
<property name="testcase" value="*"/>
<mkdir dir="${build.reports.dir}"/>
<junit printsummary="true"
showoutput="true"
errorProperty="junit.failed"
failureProperty="junit.failed"
dir="${build.reports.dir}"
fork="true">
<jvmarg value="${test.bootclasspath.arg}"/>
<formatter type="xml"/>
<batchtest todir="${build.reports.dir}">
<fileset dir="${test.src.dir}">
<include name="**/${testcase}Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="report-tests"
depends="run-tests">
<!-- Sets junit.report.format to frames if Xalan is present,
otherwise sets it to noframes. -->
<available property="junit.report.format"
value="frames"
classname="org.apache.xalan.lib.Redirect"
/>
<property name="junit.report.format" value="noframes"/>
<junitreport todir="${build.reports.dir}">
<fileset dir="${build.reports.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report styledir="${stylesheet.dir}"
format="${junit.report.format}"
todir="${build.reports.dir}"
/>
</junitreport>
<fail message="Test Cases Failed" if="junit.failed"/>
</target>
<target name="configure-compiler">
<property name="gjc.version"
value="1.3"/>
<condition property="build.novariance" value="-novariance">
<and>
<equals arg1="${gjc.version}" arg2="2.0"/>
<or>
<not><isset property="gjc.novariance"/></not>
<istrue value="${gjc.novariance}"/>
</or>
</and>
</condition>
<property name="build.novariance"
value=""/>
<property name="gjc.dir"
value="${lib.dir}/gjc"/>
<property name="javac.jar"
location="${gjc.dir}/${gjc.version}/javac.jar"/>
<property name="collect.jar"
location="${gjc.dir}/${gjc.version}/collect${build.novariance}.jar"/>
<condition property="build.warnunchecked" value="-warnunchecked">
<istrue value="${gjc.warnunchecked}"/>
</condition>
<property name="build.warnunchecked" value=""/>
<!--
! Bootclasspath munging for source compilation.
-->
<path id="javac.bootclasspath.prefix">
<!-- <pathelement location="${src.dir}"/> -->
<pathelement location="${javac.jar}"/>
</path>
<path id="javac.bootclasspath">
<!-- <pathelement location="${src.dir}"/> -->
<pathelement location="${collect.jar}"/>
<pathelement location="${rt.jar}"/>
</path>
<!-- Flatten bootclasspath prefix into a platform-appropriate string -->
<property name="javac.bootclasspath.prefix"
refid="javac.bootclasspath.prefix"/>
<!-- Turn the flattened bootclasspath prefix into a javac argument -->
<property name="build.bootclasspath.arg"
value='-J-Xbootclasspath/p:${javac.bootclasspath.prefix}'/>
<!-- Flatten bootclasspath for trace message -->
<property name="javac.bootclasspath"
refid="javac.bootclasspath"/>
<!-- Common options in javac invocations -->
<property name="build.javac.args"
value="${build.bootclasspath.arg} ${build.warnunchecked} ${build.novariance}"/>
<echo>javac ${build.javac.args}
bootclasspath is ${javac.bootclasspath}</echo>
</target>
<target name="configure-emulation">
<condition property="build.emulation.true">
<or>
<and>
<os family="windows"/>
<not>
<isset property="build.emulation"/>
</not>
</and>
<istrue value="${build.emulation}"/>
</or>
</condition>
</target>
<target name="configure-tests">
<!-- junit.framework.Protectable is in JUnit 3.8.1 but not in 3.7 -->
<available property="junit.available"
classname="junit.framework.Protectable"/>
<fail message="Need JUnit 3.8.1 in ${ant.home}${file.separator}lib to run tests"
unless="junit.available"/>
<!--
! Bootclasspath munging for testing, so JUnit can test our local
! modifications to java.*.
-->
<path id="test.classpath">
<pathelement location="${product.jar}"/>
<pathelement location="${build.testcases.dir}"/>
<pathelement location="${junit.jar}"/>
</path>
<!-- Flatten test classpath into a platform-appropriate string -->
<property name="test.classpath" refid="test.classpath"/>
<!-- Turn the flattened test classpath into a javac argument -->
<property name="test.bootclasspath.arg"
value='-Xbootclasspath/p:${test.classpath}'/>
</target>
<!-- Anthill targets -->
<target name="anthill-build"
depends="jar, test, docs, dist-docs"/>
<target name="anthill-publish">
<copy todir="${deployDir}/docs/private">
<fileset dir="${build.javadocs.dir}"/>
</copy>
<copy todir="${deployDir}/docs/public">
<fileset dir="${dist.javadocs.dir}"/>
</copy>
<copy tofile="${deployDir}/index.html"
file="${basedir}/etc/anthill-index.html"/>
<copy todir="${deployDir}/notes">
<fileset dir="${basedir}/etc/notes"/>
</copy>
</target>
</project>
| Doug Lea | ViewVC Help |
| Powered by ViewVC 1.0.8 |