<!--
$Header$
-->
<!-- *** BUILD FILE HEADER ***
This project file, along with these others, are all quite similar:
drjava: docs/build.xml
drjava: drjava/build.xml
drjava: dynamicjava/build.xml
drjava: eclipse/build.xml
drjava: jedit/build.xml
drjava: platforms/build.xml
javalanglevels: javalanglevels/build.xml
ricejst: ricejst/build.xml
In order to avoid inconsistency, changes made to one should, in general, be reflected in each of the others.
PLEASE DON'T FIX OR UPDATE ONE BUILD SCRIPT WITHOUT MIRRORING THE CHANGES IN THE OTHERS. While this approach
leads to a lot of "repeated code," the advantage is that each module is able in this way to maintain a simple,
understandable build process without external dependencies.
The following should be customized (or, if unneeded, removed) in each build file:
- The name of the project
- The test-classes, test-products, and resources patternsets
- The readable-project-name, jar-filename, src-working-dir, etc. properties
- The list of generated sources
- The list of environment variables
- The list of additional taskdefs
- The help target description
- The build target behavior (specifying the default build process)
- The list of source-generating targets
- The test target behavior (specifying the default test target)
- The list of files removed by "clean"
- The command to export CVS sources in "src-zip"
-->
<project name="drjava" default="help">
<assertions>
<enable />
</assertions>
<!-- TODO:
clover
strip-license/relicense
-->
<!-- Matches class files that are tests, and thus should be separated into
the "classes/test" directory. The search is relative to "classes/base". -->
<patternset id="test-classes">
<include name="**/*Test.class" />
<include name="**/*Test$*.class" />
<include name="**/*TestCase.class" />
<include name="**/*TestCase$*.class" />
</patternset>
<!-- Matches files that are generated by tests, but should not be committed to Subversion.
The search is relative to the testFiles directory. If additional unmatched test
products occur, *THEY SHOULD BE ADDED TO THIS SET* in order to insure that "clean"
works properly. -->
<patternset id="test-products">
<exclude name="**" />
</patternset>
<!-- Matches non-class-file resources that should be available to the executable.
The search is relative to the src directory. -->
<patternset id="resources">
<include name="**/LICENSE" />
<include name="**/README" />
<include name="**/*.gif" />
<include name="**/*.png" />
<include name="**/*.jpg" />
<include name="**/*.jpeg" />
</patternset>
<patternset id="rmi-base-classes">
<include name="edu/rice/cs/drjava/model/repl/newjvm/InterpreterJVM.class" />
<include name="edu/rice/cs/drjava/model/repl/newjvm/MainJVM.class" />
</patternset>
<patternset id="rmi-test-classes">
<include name="edu/rice/cs/util/newjvm/IntegratedMasterSlaveTest$TestMasterJVM.class" />
<include name="edu/rice/cs/util/newjvm/IntegratedMasterSlaveTest$CounterSlave.class" />
</patternset>
<property name="readable-project-name" value="DrJava" />
<property name="jar-15-filename" value="drjava-15.jar" />
<property name="jar-base-15-filename" value="drjava-base-15.jar" />
<property name="jar-14-filename" value="drjava.jar" />
<property name="jar-base-14-filename" value="drjava-base-14.jar" />
<property name="jar-main-class" value="edu.rice.cs.drjava.DrJava" />
<property name="src-working-dir" value="src/edu/rice/cs/drjava" />
<property name="svn-repository" value="https://svn.sourceforge.net/svnroot/drjava" />
<!-- Relative paths to generated sources. Note: changes to this list should be mirrorred
in the "Source-generating Targets" section and the "clean" target. -->
<property name="code-status-source" value="${src-working-dir}/CodeStatus.orig" />
<property name="code-status-target" value="${src-working-dir}/CodeStatus.java" />
<property name="version-source" value="${src-working-dir}/Version.orig" />
<property name="version-target" value="${src-working-dir}/Version.java" />
<property environment="env" />
<property name="java14-home" value="${env.JAVA14_HOME}" />
<!-- By default, don't filter tests on anything -->
<property name="test-spec" value="" />
<property name="test-list" value="" />
<!-- By default, perform the test once -->
<property name="test-repeat" value="1" />
<!-- By default, time out after a day -->
<property name="test-timeout" value="1440" />
<!-- By default, delete jar files when cleaning -->
<property name="delete-jars" value="yes" />
<!-- By default, clean can fail -->
<property name="clean-can-fail" value="yes" />
<!-- By default, don't append anything extra to the tag -->
<property name="tag-append" value="" />
<!-- By default, generate development (non-stable) build products -->
<property name="is-development" value="yes" />
<!-- Don't use or inherit the CLASSPATH environment variable for anything -->
<property name="build.sysclasspath" value="ignore" />
<fileset id="libs" dir="lib" includes="*.jar" /> <!-- Only include jars that are at the top level (not in buildlib) -->
<!-- Retroweaver task, used to convert Java 1.5 class files to be compatible with an earlier JVM;
also checks class references to insure that there are no dependencies on 1.5 APIs -->
<taskdef name="retroweaver" classpath="lib/buildlib/retroweaver-all-1.2.3.jar"
classname="com.rc.retroweaver.ant.RetroWeaverTask" />
<!-- Clover tasks, used to generate test coverage reports -->
<taskdef resource="clovertasks" classpath="lib/buildlib/clover.jar" />
<!-- Ant-Contrib additional ANT tasks -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="lib/buildlib/ant-contrib.jar"/>
<taskdef name="for" classname="net.sf.antcontrib.logic.For" classpath="lib/buildlib/ant-contrib.jar" onerror="report"/>
<!-- ***********
Help Target
*********** -->
<target name="help" description="Print general build script information">
<echo message="--------------------------------------------------------------------" />
<echo message="DrJava Build Scripts" />
<echo message="--------------------------------------------------------------------" />
<echo message="Type 'ant -projecthelp' or 'ant -p' to see the list of targets." />
<echo message="" />
<echo message="For this build file to function properly, the following environment " />
<echo message="variables should be defined:" />
<echo message="JAVA14_HOME: Home folder of the JDK (or J2SDK) version 1.4" />
<echo message="PATH: 'svn' needs to refer to the Subversion client executable" />
<echo message="" />
<echo message="Additionally, Ant must be run under Java 5.0 or later. If that is " />
<echo message="not the system default, it may be set for Ant by using JAVA_HOME." />
<echo message="Ant may also require ANT_HOME to be set. Note that the value of " />
<echo message="CLASSPATH will be ignored -- classes on the system classpath will " />
<echo message="not be visible during the build process. To run JUnit tests," />
<echo message="a copy of junit.jar should be installed in the Ant lib directory." />
<echo message="" />
<echo message="For the test, test-15, test-14, and test-14-in-15 targets, the" />
<echo message="tests to run can be filtered using the -Dtest-spec=... and" />
<echo message="-Dtest-list=... command line parameters." />
<echo message="" />
<echo message="-Dtest-spec=... includes all test files whose names end with" />
<echo message=""Test.class" and contain the characters specified after" />
<echo message="the = sign." />
<echo message="" />
<echo message="-Dtest-list=... includes all tests files listed after the = sign." />
<echo message="Multiple files can be specified by as a space-separated list" />
<echo message="surrounded by quotation marks." />
<echo message="" />
<echo message="If neither -Dtest-spec=... nor -Dtest-list=... is specified, all" />
<echo message="test files ending with "Test.class" are included." />
<echo message="" />
<echo message="Examples:" />
<echo message="ant test -Dtest-spec=Project" />
<echo message="ant test -Dtest-list="edu/rice/cs/drjava/ui/ProjectMenuTest.class edu/rice/cs/drjava/ui/MainFrameTest.class"" />
<echo message="ant test -Dtest-spec=Global -Dtest-list="edu/rice/cs/drjava/ui/ProjectMenuTest.class"" />
<echo message="" />
<echo message="Using -Dtest-repeat="...", a test can be repeated several" />
<echo message="times. The number is controlled by the number of items in the" />
<echo message="comma-separated list: -Dtest-repeat="1,2,3" repeats the" />
<echo message="tests three times." />
<echo message="" />
<echo message="With -Dtest-timeout=..., the timeout duration can be specified" />
<echo message="in minutes: -Dtest-timeout=5 aborts the tests after 5 minutes," />
<echo message="and the task will fail." />
</target>
<!-- ***************************
Property-resolution Targets
*************************** -->
<target name="resolve-java14-runtime">
<!-- We rely on "location" to generate a platform-specific path; note that properties
are immutable and so java14-runtime will only be set the *first* time. -->
<property name="java14-runtime-1" location="${java14-home}/lib/rt.jar" />
<available property="java14-runtime" value="${java14-runtime-1}" file="${java14-runtime-1}" />
<property name="java14-runtime-2" location="${java14-home}/jre/lib/rt.jar" />
<available property="java14-runtime" value="${java14-runtime-2}" file="${java14-runtime-2}" />
<property name="java14-runtime-3" location="${java14-home}/../Classes/classes.jar" />
<available property="java14-runtime" value="${java14-runtime-3}" file="${java14-runtime-3}" />
<fail message="Can't find rt.jar in the Java 1.4 home: ${java14-home}" unless="java14-runtime" />
</target>
<target name="resolve-java14-exec">
<!-- We rely on "location" to generate a platform-specific path -->
<property name="java14-exec-1" location="${java14-home}/bin/java.exe" />
<condition property="java14-exec" value="${java14-exec-1}">
<and>
<available file="${java14-exec-1}" />
<os family="windows" />
</and>
</condition>
<property name="java14-exec-2" location="${java14-home}/bin/java" />
<available property="java14-exec" value="${java14-exec-2}" file="${java14-exec-2}" />
<fail message="Can't find the java executable in the Java 1.4 home: ${java14-home}" unless="java14-exec" />
</target>
<target name="resolve-java14-tools">
<!-- We rely on "location" to generate a platform-specific path; note that properties
are immutable and so java15-tools will only be set the *first* time. -->
<property name="java14-tools-1" location="${java14-home}/lib/tools.jar" />
<available property="java14-tools" value="${java14-tools-1}" file="${java14-tools-1}" />
<property name="java14-tools-2" location="${java14-home}/jre/lib/tools.jar" />
<available property="java14-tools" value="${java14-tools-2}" file="${java14-tools-2}" />
<property name="java14-tools-3" location="${java14-home}/../Classes/classes.jar" />
<available property="java14-tools" value="${java14-tools-3}" file="${java14-tools-3}" />
<fail message="Can't find tools.jar in the Java 1.4 home: ${java14-home}" unless="java14-tools" />
</target>
<target name="resolve-java15-tools" depends="assert-15">
<!-- We rely on "location" to generate a platform-specific path; note that properties
are immutable and so java15-tools will only be set the *first* time. -->
<property name="java15-tools-1" location="${java.home}/../lib/tools.jar" />
<available property="java15-tools" value="${java15-tools-1}" file="${java15-tools-1}" />
<property name="java15-tools-2" location="${java.home}/../Classes/classes.jar" />
<available property="java15-tools" value="${java15-tools-2}" file="${java15-tools-2}" />
<fail message="Can't find tools.jar in the Java 1.5 home: ${java.home}" unless="java15-tools" />
</target>
<target name="assert-15">
<fail message="The specified target requires Ant to be run under Java 5.0">
<condition>
<not>
<or>
<contains string="${java.version}" substring="1.5." />
<contains string="${java.version}" substring="1.6." />
</or>
</not>
</condition>
</fail>
</target>
<target name="assert-jar-exists">
<available property="jar-exists" file="${ant.project.name}.jar" />
<fail message="Can't find ${ant.project.name}.jar" unless="jar-exists" />
</target>
<target name="resolve-development-value">
<condition property="development-value" value="true">
<istrue value="${is-development}" />
</condition>
<!-- else... -->
<property name="development-value" value="false" />
</target>
<target name="resolve-version-tag">
<!-- Get a timestamp based on GMT, rather than local time -->
<tstamp>
<format property="DSTAMP" pattern="yyyyMMdd" timezone="GMT" />
<format property="TSTAMP" pattern="HHmm" timezone="GMT" />
<format property="TODAY" pattern="MMMM dd yyyy" timezone="GMT" />
</tstamp>
<property name="version-tag"
value="${ant.project.name}${tag-append}-${DSTAMP}-${TSTAMP}" />
</target>
<target name="resolve-cvs-user-name">
<input message="Please enter your CVS user name: " addproperty="cvs-user-name" />
</target>
<target name="resolve-svn-user-name">
<input message="Please enter your Subversion user name: " addproperty="svn-user-name" />
</target>
<!-- Sets "already-generated" if "generate-file" is more recent than "generate-sourcefile";
otherwise, the out-of-date target file is deleted (if it exists). Note that, since
properties can only be set once, this should happen underneath an "antcall". -->
<target name="check-generate-file-from-file">
<dependset>
<srcfilelist dir="${basedir}" files="${generate-sourcefile}" />
<targetfilelist dir="${basedir}" files="${generate-file}" />
</dependset>
<available file="${generate-file}" property="already-generated" />
</target>
<!-- Sets "already-generated" if "generate-file" is more recent than everything in
"generate-sourcedir"; otherwise, the out-of-date target file is deleted (if it exists).
Note that, since properties can only be set once, this should happen underneath an "antcall". -->
<target name="check-generate-file-from-dir">
<dependset>
<srcfileset dir="${generate-sourcedir}" />
<targetfilelist dir="${basedir}" files="${generate-file}" />
</dependset>
<available file="${generate-file}" property="already-generated" />
</target>
<!-- Sets "already-generated" if "generate-dir" was created (or modified) more recently
than "generate-sourcefile". Note that, since properties can only be set once, this
should happen underneath an "antcall". -->
<target name="check-generate-dir-from-file">
<uptodate property="already-generated" targetfile="${generate-dir}" srcfile="${generate-sourcefile}" />
</target>
<!-- Sets "already-generated" if "generate-dir" was created (or modified) more recently
than everything in "generate-sourcedir". Note that, since properties can only be
set once, this should happen underneath an "antcall". -->
<target name="check-generate-dir-from-dir">
<!-- Unfortunately, a bug in uptodate prevents this from working properly,
so we just have to equate *existence* with being up to date.
<uptodate property="already-generated" targetfile="${generate-dir}" >
<srcfiles dir="${generate-sourcedir}" />
</uptodate>
-->
<available file="${generate-dir}" property="already-generated" />
</target>
<!-- ************
Build Target
************ -->
<target name="build" depends="test-14-in-15, jar-14"
description="Shortcut for 'test-14-in-15' and 'jar-14'">
</target>
<!-- *************************
Source-generating Targets
************************* -->
<target name="generate-source" depends="resolve-development-value, resolve-version-tag"
description="Generate the CodeStatus and Version source files">
<filter token="DEVELOPMENT" value="${development-value}" />
<filter token="DATE" value="${DSTAMP}" />
<filter token="TIME" value="${TSTAMP}" />
<echo message="Processing ${code-status-source}" />
<copy file="${code-status-source}" tofile="${code-status-target}" filtering="yes" />
<echo message="Processing ${version-source}" />
<copy file="${version-source}" tofile="${version-target}" filtering="yes" />
</target>
<!-- *******************
Compilation Targets
******************* -->
<target name="compile" depends="compile-15" description="Shortcut for 'compile-15'">
</target>
<target name="compile-15" depends="generate-source, check-rmi-compile, do-compile, rmi-compile, copy-resources, unjar-libs"
description="Compile all source files (after generating the source)">
</target>
<target name="do-compile" depends="assert-15, resolve-java15-tools">
<echo message="Compiling src directory to classes/base and classes/test" />
<mkdir dir="classes/base" />
<mkdir dir="classes/test" />
<!-- Move any test classes back to base to prevent recompilation -->
<move todir="classes/base">
<fileset dir="classes/test" />
</move>
<javac srcdir="src" destdir="classes/base" source="1.5" target="1.5" sourcepath=""
debug="on" optimize="off" deprecation="on" includeAntRuntime="no" fork="yes">
<classpath>
<!-- TODO: Remove this dependency on tools.jar by refactoring and moving all the dependent
debugger code into the "platform" module -->
<pathelement location="${java15-tools}" />
<fileset refid="libs" />
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="classes/base" />
</classpath>
<compilerarg value="-Xlint" />
<!-- Ignore serial warnings, because they occur for every Throwable definition (among others) -->
<compilerarg value="-Xlint:-serial" />
<!-- Use the next line to compile against other sources, ignoring any unneeded classes.
This can be useful in creating a pruned version of a jar file for the lib directory.
(You must also clear the sourcepath="" option.)
<include name="${src-working-dir}/**/*.java" /> -->
</javac>
<move todir="classes/test">
<fileset dir="classes/base">
<patternset refid="test-classes" />
</fileset>
</move>
</target>
<!-- This check has to happen *before* do-compile; otherwise, the rmi class files will
always be up to date -->
<target name="check-rmi-compile">
<condition property="rmi-classes-uptodate">
<and>
<available file="classes/base" type="dir" />
<available file="classes/test" type="dir" />
<not>
<or>
<!-- If a source is "up to date" with respect to its class file
(reversing the usual order), the class file is out of date. This
allows for a one-to-many relationship between a source and its classes. -->
<uptodate>
<srcfiles dir="classes/base">
<patternset refid="rmi-base-classes" />
</srcfiles>
<!-- Regular expression copied from the Ant manual; they say it maps from
classes to their sources -->
<mapper type="regexp" from="^(.*?)(\$$[^/\\\.]*)?\.class$$" to="\1.java" />
</uptodate>
<uptodate>
<srcfiles dir="classes/test">
<patternset refid="rmi-test-classes" />
</srcfiles>
<mapper type="regexp" from="^(.*?)(\$$[^/\\\.]*)?\.class$$" to="\1.java" />
</uptodate>
</or>
</not>
</and>
</condition>
</target>
<target name="rmi-compile" depends="check-rmi-compile, resolve-java15-tools" unless="rmi-classes-uptodate">
<echo message="Compiling RMI classes" />
<rmic base="classes/base" includeAntRuntime="no">
<patternset refid="rmi-base-classes" />
<classpath>
<pathelement location="${java15-tools}" />
<fileset refid="libs" />
<pathelement location="classes/base" />
</classpath>
</rmic>
<rmic base="classes/test" includeAntRuntime="no">
<patternset refid="rmi-test-classes" />
<classpath>
<pathelement location="${java15-tools}" />
<fileset refid="libs" />
<pathelement location="classes/base" />
<pathelement location="classes/test" />
</classpath>
</rmic>
</target>
<target name="copy-resources">
<copy todir="classes/base">
<fileset dir="src">
<patternset refid="resources" />
</fileset>
</copy>
</target>
<target name="unjar-libs">
<antcall target="do-unjar-libs">
<param name="generate-sourcedir" value="lib" />
<param name="generate-dir" value="classes/lib" />
</antcall>
</target>
<target name="do-unjar-libs" depends="check-generate-dir-from-dir" unless="already-generated">
<echo message="Unjarring jar files in the lib directory" />
<!-- Delete "classes/lib" in case it exists (but is out of date) -->
<delete dir="classes/lib" />
<mkdir dir="classes/lib" />
<unjar dest="classes/lib">
<fileset refid="libs" />
<patternset excludes="META-INF/**" />
</unjar>
</target>
<target name="compile-14" depends="compile-15, resolve-java14-runtime, resolve-java14-tools"
description="Create 1.4 versions of the classes (after compiling)">
<!-- Note: This target, in addition to checking 1.4 compatibility, serves to ensure that there are no dependencies
on test classes or JUnit classes in the base. If 1.4 compatibility is no longer needed, a similar dependency
check should probably still be done. -->
<echo message="Generating 1.4 versions of the classes directories (this may take awhile after a large compile)" />
<!-- Convert lib classes -->
<mkdir dir="classes/lib-14" />
<retroweaver srcdir="classes/lib" destdir="classes/lib-14" target="1.4" verify="no" />
<copy todir="classes/lib-14">
<fileset dir="classes/lib" excludes="**/*.class" />
</copy>
<!-- Convert base classes -->
<mkdir dir="classes/base-14" />
<pathconvert property="retroweaver-base-classpath" dirsep="${file.separator}" pathsep="${path.separator}">
<path>
<pathelement location="${java14-runtime}" />
<pathelement location="${java14-tools}" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
</path>
</pathconvert>
<retroweaver srcdir="classes/base" destdir="classes/base-14" target="1.4" verify="yes"
classpath="${retroweaver-base-classpath}" />
<copy todir="classes/base-14">
<fileset dir="classes/base" excludes="**/*.class" />
</copy>
<!-- Convert test classes -->
<mkdir dir="classes/test-14" />
<pathconvert property="retroweaver-test-classpath" dirsep="${file.separator}" pathsep="${path.separator}">
<path>
<pathelement location="${java14-runtime}" />
<pathelement location="${java14-tools}" />
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
<pathelement location="classes/test-14" />
</path>
</pathconvert>
<!-- We do not check references here, thus allowing 1.5 references in test classes -->
<retroweaver srcdir="classes/test" destdir="classes/test-14" target="1.4" verify="no" />
<copy todir="classes/test-14">
<fileset dir="classes/test" excludes="**/*.class" />
</copy>
</target>
<!-- ***************
Testing Targets
*************** -->
<target name="test" depends="test-15" description="Shortcut for 'test-15'">
</target>
<target name="test-15" depends="compile-15, assert-15, resolve-java15-tools"
description="Run all 5.0 tests under Java 5.0 (after compiling); use -Dtest-spec=... and -Dtest-list=... to filter">
<if>
<and>
<not>
<equals arg1="${test-spec}" arg2=""/>
</not>
<equals arg1="${test-list}" arg2=""/>
</and>
<then>
<echo message="Running all 5.0 tests matching '${test-spec}' under Java 5.0"/>
<property name="use-test-spec" value="true"/>
</then>
<elseif>
<and>
<not>
<equals arg1="${test-list}" arg2=""/>
</not>
<equals arg1="${test-spec}" arg2=""/>
</and>
<then>
<echo message="Running the 5.0 tests '${test-list}' under Java 5.0"/>
<property name="use-test-list" value="true"/>
</then>
</elseif>
<elseif>
<and>
<not>
<equals arg1="${test-spec}" arg2=""/>
</not>
<not>
<equals arg1="${test-list}" arg2=""/>
</not>
</and>
<then>
<echo message="Running the 5.0 tests '${test-list}' and those matching '${test-spec}' under Java 5.0"/>
<property name="use-test-spec" value="true"/>
<property name="use-test-list" value="true"/>
</then>
</elseif>
<else>
<echo message="Running all 5.0 tests under Java 5.0."/>
<property name="use-test-all" value="true"/>
</else>
</if>
<for list="${test-repeat}" param="iteration">
<sequential>
<limit maxwait="${test-timeout}" maxwaitunit="minute" failonerror="true">
<junit haltonfailure="yes" fork="yes" forkmode="perTest" maxmemory="256M" dir="${basedir}">
<classpath>
<pathelement location="${java15-tools}" />
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="classes/test" />
<pathelement location="classes/base" />
<pathelement location="classes/lib" />
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="classes/test" includes="${test-list}">
<include name="**/*Test.class" if="use-test-all"/>
<include name="**/*${test-spec}*Test.class" if="use-test-spec"/>
</fileset>
</batchtest>
</junit>
</limit>
</sequential>
</for>
</target>
<target name="test-14" depends="compile-14, resolve-java14-exec, resolve-java14-tools"
description="Run all 1.4 tests under Java 1.4 (after compiling); use -Dtest-spec=... and -Dtest-list=... to filter">
<if>
<and>
<not>
<equals arg1="${test-spec}" arg2=""/>
</not>
<equals arg1="${test-list}" arg2=""/>
</and>
<then>
<echo message="Running all 1.4 tests matching '${test-spec}' under Java 5.0"/>
<property name="use-test-spec" value="true"/>
</then>
<elseif>
<and>
<not>
<equals arg1="${test-list}" arg2=""/>
</not>
<equals arg1="${test-spec}" arg2=""/>
</and>
<then>
<echo message="Running the 1.4 tests '${test-list}' under Java 1.4"/>
<property name="use-test-list" value="true"/>
</then>
</elseif>
<elseif>
<and>
<not>
<equals arg1="${test-spec}" arg2=""/>
</not>
<not>
<equals arg1="${test-list}" arg2=""/>
</not>
</and>
<then>
<echo message="Running the 1.4 tests '${test-list}' and those matching '${test-spec}' under Java 1.4"/>
<property name="use-test-spec" value="true"/>
<property name="use-test-list" value="true"/>
</then>
</elseif>
<else>
<echo message="Running all 1.4 tests under Java 1.4."/>
<property name="use-test-all" value="true"/>
</else>
</if>
<echo message="WARNING: 1.4-compatible test classes are (intentionally) not checked for Java 5 API references." />
<echo message="If such references exist, these tests will probably fail." />
<for list="${test-repeat}" param="iteration">
<sequential>
<limit maxwait="${test-timeout}" maxwaitunit="minute" failonerror="true">
<junit haltonfailure="yes" fork="yes" forkmode="perTest" maxmemory="256M" jvm="${java14-exec}" dir="${basedir}">
<classpath>
<pathelement location="${java14-tools}" />
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="classes/test-14" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="classes/test-14" includes="${test-list}">
<include name="**/*Test.class" if="use-test-all"/>
<include name="**/*${test-spec}*Test.class" if="use-test-spec"/>
</fileset>
</batchtest>
</junit>
</limit>
</sequential>
</for>
</target>
<target name="test-14-in-15" depends="compile-14, assert-15, resolve-java15-tools"
description="Run all 1.4 tests under Java 5.0 (after compiling); use -Dtest-spec=... and -Dtest-list=... to filter">
<if>
<and>
<not>
<equals arg1="${test-spec}" arg2=""/>
</not>
<equals arg1="${test-list}" arg2=""/>
</and>
<then>
<echo message="Running all 1.4 tests matching '${test-spec}' under Java 5.0"/>
<property name="use-test-spec" value="true"/>
</then>
<elseif>
<and>
<not>
<equals arg1="${test-list}" arg2=""/>
</not>
<equals arg1="${test-spec}" arg2=""/>
</and>
<then>
<echo message="Running the 1.4 tests '${test-list}' under Java 5.0"/>
<property name="use-test-list" value="true"/>
</then>
</elseif>
<elseif>
<and>
<not>
<equals arg1="${test-spec}" arg2=""/>
</not>
<not>
<equals arg1="${test-list}" arg2=""/>
</not>
</and>
<then>
<echo message="Running the 1.4 tests '${test-list}' and those matching '${test-spec}' under Java 5.0"/>
<property name="use-test-spec" value="true"/>
<property name="use-test-list" value="true"/>
</then>
</elseif>
<else>
<echo message="Running all 1.4 tests under Java 5.0."/>
<property name="use-test-all" value="true"/>
</else>
</if>
<for list="${test-repeat}" param="iteration">
<sequential>
<limit maxwait="${test-timeout}" maxwaitunit="minute" failonerror="true">
<junit haltonfailure="yes" fork="yes" forkmode="perTest" maxmemory="256M" dir="${basedir}">
<classpath>
<pathelement location="${java15-tools}" />
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="classes/test-14" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="classes/test-14" includes="${test-list}">
<include name="**/*Test.class" if="use-test-all"/>
<include name="**/*${test-spec}*Test.class" if="use-test-spec"/>
</fileset>
</batchtest>
</junit>
</limit>
</sequential>
</for>
</target>
<target name="run" depends="run-15" description="Shortcut for 'run-15'">
</target>
<target name="run-15" depends="compile-15, assert-15, resolve-java15-tools"
description="Run the DrJava 5.0 classes under Java 5.0 (after compiling)">
<echo message="Running the DrJava application (5.0 classes in Java 5.0)" />
<java classname="${jar-main-class}" fork="yes" spawn="yes">
<classpath>
<pathelement location="${java15-tools}" />
<pathelement location="classes/base" />
<pathelement location="classes/lib" />
</classpath>
</java>
</target>
<target name="run-14" depends="compile-14, resolve-java14-exec, resolve-java14-tools"
description="Run the DrJava 1.4 classes under Java 1.4 (after compiling)">
<echo message="Running the DrJava application (1.4 classses in Java 1.4)" />
<java classname="${jar-main-class}" jvm="${java14-exec}" fork="yes" spawn="yes">
<classpath>
<pathelement location="${java14-tools}" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
</classpath>
</java>
</target>
<target name="run-14-in-15" depends="compile-14, assert-15, resolve-java15-tools"
description="Run the DrJava 1.4 classes under Java 5.0 (after compiling)">
<echo message="Running the DrJava application (1.4 classses in Java 5.0)" />
<java classname="${jar-main-class}" fork="yes" spawn="yes">
<classpath>
<pathelement location="${java15-tools}" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
</classpath>
</java>
</target>
<!-- ***********
Jar Targets
*********** -->
<target name="jar" depends="jar-15" description="Shortcut for 'jar-15'" />
<target name="jar-15" depends="compile-15, resolve-version-tag"
description="Create the jar file with all classes and libs (compiling first)">
<jar jarfile="${jar-15-filename}">
<manifest>
<attribute name="Main-Class" value="${jar-main-class}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Version" value="${version-tag}" />
</manifest>
<fileset dir="classes/lib" />
<fileset dir="classes/base" />
</jar>
</target>
<target name="jar-base-15" depends="compile-15, resolve-version-tag"
description="Create the jar file without any support libs (compiling first)">
<jar jarfile="${jar-base-15-filename}">
<manifest>
<attribute name="Main-Class" value="${jar-main-class}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Version" value="${version-tag}" />
</manifest>
<fileset dir="classes/base" />
</jar>
</target>
<target name="jar-14" depends="compile-14, resolve-version-tag"
description="Create the 1.4 jar file with all classes and libs (compiling first)">
<jar jarfile="${jar-14-filename}">
<manifest>
<attribute name="Main-Class" value="${jar-main-class}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Version" value="${version-tag}" />
</manifest>
<fileset dir="classes/lib-14" />
<fileset dir="classes/base-14" />
</jar>
</target>
<target name="jar-base-14" depends="compile-14, resolve-version-tag"
description="Create the 1.4 jar file without any support libs (compiling first)">
<jar jarfile="${jar-base-14-filename}">
<manifest>
<attribute name="Main-Class" value="${jar-main-class}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Version" value="${version-tag}" />
</manifest>
<fileset dir="classes/base-14" />
</jar>
</target>
<!-- *********************
Documentation Targets
********************* -->
<target name="javadoc" depends="generate-source, assert-15, resolve-version-tag, resolve-java15-tools"
description="Generate javadocs from the source folder (generating source first)">
<antcall target="do-javadoc">
<param name="generate-sourcedir" value="src" />
<param name="generate-dir" value="docs/javadoc" />
</antcall>
</target>
<target name="do-javadoc" depends="check-generate-dir-from-dir" unless="already-generated">
<echo message="Generating javadocs" />
<delete dir="docs/javadoc" />
<mkdir dir="docs/javadoc" />
<javadoc sourcepath="src" packagenames="*" destdir="docs/javadoc"
access="protected" Use="yes" Version="yes" Author="yes" Windowtitle="${version-tag} API">
<classpath>
<pathelement location="${java15-tools}" />
<fileset refid="libs" />
<pathelement location="lib/buildlib/junit.jar" />
</classpath>
<link href="/?originalUrl=https%3A%2F%2Fsourceforge.net%2F%253C%2Fspan">"http://java.sun.com/j2se/1.5/docs/api" />
<link href="/?originalUrl=https%3A%2F%2Fsourceforge.net%2F%253C%2Fspan">"http://junit.org/junit/javadoc/3.8.1" />
</javadoc>
</target>
<!-- ************
Clean Target
************ -->
<target name="clean" unless="skip-clean"
description="Remove all build products; the result should match the intended Subversion contents">
<echo message="Deleting all build products" />
<delete dir="classes" failonerror="${clean-can-fail}" />
<delete dir="docs" failonerror="${clean-can-fail}" />
<delete failonerror="${clean-can-fail}">
<fileset dir="testFiles">
<patternset refid="test-products" />
</fileset>
</delete>
<condition property="do-delete-jars">
<istrue value="${delete-jars}" />
</condition>
<delete includeemptydirs="true" failonerror="${clean-can-fail}">
<fileset dir="${basedir}" defaultexcludes="no">
<include name="*.jar" if="do-delete-jars" />
<include name="*.zip" if="do-delete-jars" />
<include name="*.tar.gz" if="do-delete-jars" />
<include name="${ant.project.name}-*" />
<include name="${code-status-target}" />
<include name="${version-target}" />
<include name="src/**/*.class" />
<!-- We could get rid of backups, but "update" ignores them, so they're okay.
(doesn't work if defaultexcludes is "yes") -->
<!-- <include name="**/*~" /> -->
<!-- Get rid of pesky OS helper files (doesn't work if defaultexcludes is "yes") -->
<include name="**/.DS_Store" />
<include name="**/Thumbs.db" />
</fileset>
</delete>
</target>
<!-- ***********
CVS Targets
*********** -->
<target name="update-cvs" depends="clean">
<echo message="Running CVS update ('-q' -- you will only see output for files that don't match)" />
<!-- TODO: Experiment with the 'compression' option -->
<cvs command="update -d -P" quiet="true" />
</target>
<target name="commit-cvs" depends="update-cvs, build, do-commit-cvs, tag-cvs">
<echo message="New version is committed to CVS" />
</target>
<target name="do-commit-cvs">
<antcall target="clean"> <!-- Clean up after the latest build -->
<param name="delete-jars" value="no" />
<param name="clean-can-fail" value="no" />
</antcall>
<input message="Please enter a log message for the commit: "
addproperty="cvs.commit.message" />
<echo message="Running CVS commit"/>
<cvs quiet="true">
<commandline>
<argument value="commit" />
<argument value="-m" />
<argument value="${cvs.commit.message}" />
</commandline>
</cvs>
</target>
<target name="tag-cvs" depends="resolve-version-tag">
<echo message="Running CVS tag with version ${version-tag}"/>
<cvs command="tag -c ${version-tag}" reallyquiet="true" />
</target>
<!-- ******************
Subversion Targets
****************** -->
<target name="update" depends="clean" description="Reconcile source with the Subversion archive">
<echo message="Running Subversion update" />
<exec executable="svn" failonerror="yes">
<arg value="update" />
</exec>
<exec executable="svn" failonerror="yes">
<arg value="status" />
</exec>
</target>
<target name="commit" depends="update, build"
description="Commit source to the Subversion archive (after building)">
<antcall target="clean"> <!-- Clean up after the latest build -->
<param name="delete-jars" value="no" />
<param name="clean-can-fail" value="no" />
</antcall>
<exec executable="svn" failonerror="yes">
<arg value="status" />
</exec>
<input message="Please enter a log message for the commit: "
addproperty="svn-commit-message" />
<echo message="Running Subversion commit" />
<exec executable="svn" failonerror="yes">
<arg value="commit" />
<arg value="-m" />
<arg value="${svn-commit-message}" />
</exec>
</target>
<target name="tag" depends="resolve-version-tag"
description="Copy the working copy to a new Subversion tag">
<echo message="Creating a new Subversion tag with name ${version-tag}"/>
<exec executable="svn" failonerror="yes">
<arg value="copy" />
<arg value="${basedir}" />
<arg value="${svn-repository}/tags/${version-tag}" />
<arg value="-m" />
<arg value="Created tag ${version-tag}" />
</exec>
</target>
<target name="branch" description="Copy the working copy to a new Subversion branch">
<input message="Enter a name for the new branch: "
addproperty="svn-branch-name" />
<echo message="Creating a new Subversion branch ${svn-branch-name}" />
<exec executable="svn" failonerror="yes">
<arg value="copy" />
<arg value="${basedir}" />
<arg value="${svn-repository}/branches/${svn-branch-name}" />
<arg value="-m" />
<arg value="Created branch ${svn-branch-name}" />
</exec>
</target>
<!-- ***************
Release Targets
*************** -->
<target name="release-stable" description="Generate all release files tagged with 'stable'">
<antcall target="release">
<param name="tag-append" value="-stable" />
<param name="is-development" value="no" />
</antcall>
</target>
<target name="release-beta" description="Generate all release files tagged with 'beta'">
<antcall target="release">
<param name="tag-append" value="-beta" />
<param name="is-development" value="no" />
</antcall>
</target>
<target name="release" depends="update, build, resolve-version-tag, tag, jar-app, mac-app, windows-app, src-zip, javadoc-zip"
description="Generate all release files (after building)">
<delete dir="${version-tag}" />
</target>
<target name="jar-app" depends="assert-jar-exists, resolve-version-tag">
<echo message="Creating ${version-tag}.jar" />
<copy file="${ant.project.name}.jar" tofile="${version-tag}.jar" />
</target>
<target name="mac-app" depends="assert-jar-exists, resolve-version-tag">
<echo message="Creating ${version-tag}-osx.tar.gz" />
<property name="mac-app-dir" value="${version-tag}/osx" />
<mkdir dir="${mac-app-dir}" />
<filter token="VERSION" value="${version-tag}" />
<copy todir="${mac-app-dir}/${readable-project-name}.app" filtering="yes" >
<fileset dir="packaging/${readable-project-name}.app" excludes="**/*jar-goes-here" />
</copy>
<copy file="${ant.project.name}.jar"
todir="${mac-app-dir}/${readable-project-name}.app/Contents/Resources/Java" />
<tar tarfile="${mac-app-dir}/${version-tag}-osx.tar">
<tarfileset dir="${mac-app-dir}" includes="${readable-project-name}.app/**"
excludes="${readable-project-name}.app/Contents/MacOS/${readable-project-name}" />
<tarfileset dir="${mac-app-dir}" mode="755"
includes="${readable-project-name}.app/Contents/MacOS/${readable-project-name}" />
</tar>
<gzip src="/?originalUrl=https%3A%2F%2Fsourceforge.net%2F%253C%2Fspan">"${mac-app-dir}/${version-tag}-osx.tar" destfile="${version-tag}-osx.tar.gz" />
</target>
<target name="windows-app" depends="assert-jar-exists, resolve-version-tag">
<echo message="Creating ${version-tag}.exe" />
<concat destfile="${version-tag}.exe" binary="yes">
<filelist dir="${basedir}">
<!-- TODO: This should probably include WinExecutor.exe and the icon file
rather than using the generated WinExecutorFor... -->
<file name="packaging/WinExecutorFor${readable-project-name}.exe" />
<file name="${ant.project.name}.jar" />
</filelist>
</concat>
</target>
<target name="src-zip" depends="resolve-version-tag">
<echo message="Creating ${version-tag}-src.zip" />
<exec executable="svn" failonerror="yes">
<arg value="export" />
<arg value="${svn-repository}/tags/${version-tag}" />
<arg value="${version-tag}/src" />
</exec>
<zip destfile="${version-tag}-src.zip">
<zipfileset dir="${version-tag}/src" prefix="${version-tag}/src" />
</zip>
</target>
<target name="src-zip-cvs" depends="resolve-version-tag, resolve-cvs-user-name">
<echo message="Creating ${version-tag}-src.zip" />
<mkdir dir="${version-tag}/src" />
<cvs cvsRoot="${cvs-user-name}@cvs.sf.net:/cvsroot/drjava" command="export -N" dest="${version-tag}/src"
tag="${version-tag}" quiet="yes" package="drjava" />
<zip destfile="${version-tag}-src.zip">
<zipfileset dir="${version-tag}/src" prefix="${version-tag}/src" />
</zip>
</target>
<target name="javadoc-zip" depends="javadoc, resolve-version-tag">
<echo message="Creating ${version-tag}-javadoc.zip" />
<zip destfile="${version-tag}-javadoc.zip">
<zipfileset dir="docs/javadoc" prefix="${version-tag}/javadoc" />
</zip>
</target>
<!-- ********************************
Misc Occasionally-Useful Targets
******************************** -->
<patternset id="exclude-binaries">
<exclude name="**/*.jar" />
<exclude name="**/*.class" />
<exclude name="**/DrJava" />
<exclude name="**/*.png" />
<exclude name="**/*.icns" />
<exclude name="**/*.gif" />
<exclude name="**/*.jpg" />
<exclude name="**/*.jpeg" />
</patternset>
<!-- Run a batch find-and-replace on all text files in the project.
Assumes the properties "find" and "replace" have been defined
(e.g. "ant -Dfind=foo -Dreplace=bar find-and-replace"). -->
<target name="find-and-replace">
<replace dir="${basedir}" token="${find}" value="${replace}" summary="yes">
<patternset refid="exclude-binaries" />
</replace>
</target>
<!-- Standardize all newline character sequences. Subversion takes care of this
automatically, but sometimes files crop up with the wrong sequence.
Use "cvs update" after running this to see which files were fixed. -->
<target name="fix-newlines" description="Standardize newline character sequences in all text files">
<!-- If we're in Windows, use \r\n -->
<condition property="newline-code" value="crlf">
<os family="windows" />
</condition>
<!-- Otherwise, use \n -->
<property name="newline-code" value="lf" />
<fixcrlf srcdir="${basedir}" eol="${newline-code}" fixlast="no">
<patternset refid="exclude-binaries" />
</fixcrlf>
</target>
</project>