<!-- DrJava Eclipse Plug-in Build Script -->
<!-- This build script is based on the template located at "trunk/misc/build-template.xml"
in the DrJava Subversion repository. In general, changes made to the script should be
reflected in the template as well. -->
<project name="eclipse" default="help">
<property name="eclipse-version" value="0.9.8" />
<property name="readable-project-name" value="DrJava Eclipse Plug-in" />
<property name="src-working-dir" value="src/edu/rice/cs/drjava" />
<property name="svn-repository" value="https://svn.sourceforge.net/svnroot/drjava" />
<property environment="env" />
<property name="java14-home" value="${env.JAVA14_HOME}" />
<property name="eclipse-home" value="${env.ECLIPSE_HOME}" />
<property name="drjava-src" value="${env.DRJAVA_SRC}" />
<property name="clover-jar" value="${env.CLOVER_JAR}" />
<!-- Testing defaults -->
<property name="test-spec" value="" />
<property name="test-repeat" value="1" /> <!-- TODO: Use this value -->
<property name="test-timeout" value="1440" />
<!-- 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="" />
<!-- 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) -->
<fileset id="eclipse-libs" dir="${eclipse-home}/plugins" includes="org.eclipse.*.jar" />
<!-- Retroweaver task, used to convert Java 5.0 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" />
<!-- Extension that defines the "extendclasspath" task. This should be a standard feature of Ant, but
as long as it's not, we can use this extension from the Clover developers. -->
<taskdef resource="com/cenqua/ant/antlib.xml" classpath="lib/buildlib/cenquatasks.jar" />
<extendclasspath path="lib/buildlib/junit.jar" />
<!-- Extension containing various tools, including "for" and "if" -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="lib/buildlib/ant-contrib.jar"/>
<!-- ***********
Help Target
*********** -->
<target name="help" description="Print general build script information">
<echo message="--------------------------------------------------------------------" />
<echo message="${readable-project-name} 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 Java 1.4 JRE or J2SDK" />
<echo message="ECLIPSE_HOME: Location of the 'eclipse' application folder" />
<echo message="DRJAVA_SRC: Location of the DrJava sources. These are included on the " />
<echo message=" sourcepath during compilation; any sources referenced by the" />
<echo message=" plugin will be included in the jar." />
<echo message="PATH: 'svn' needs to refer to the Subversion client executable" />
<echo message="CLOVER_JAR: Location of the Clover jar file (necessary only if " />
<echo message=" Clover targets will be used)"/>
<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." />
</target>
<!-- ************
Build Target
************ -->
<target name="build" depends="jar-14" description="Shortcut for 'jar-14'">
</target>
<!-- test-14-in-15 should be here, but has been removed until testing works correctly
<target name="build" depends="test-14-in-15, jar-14"
description="Shortcut for 'test-14-in-15' and 'jar-14'">
</target>
-->
<!-- *******************
Compilation Targets
******************* -->
<target name="compile" depends="compile-15" description="Shortcut for 'compile-15'">
</target>
<target name="compile-15" depends="check-rmi-compile, do-compile, rmi-compile, copy-resources, unjar-libs"
description="Compile all source files">
</target>
<target name="do-compile" depends="assert-eclipse-exists, assert-drjava-src-exists, assert-15">
<echo message="Compiling src directory to classes/base and classes/test" />
<echo message="NOTE: The 'generate-source' target of the drjava build script is assumed to" />
<echo message="have been run. Otherwise, you may encounter unexpected compilation errors." />
<echo message="" />
<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" includes="**/*" />
</move>
<!--<javac srcdir="src" destdir="classes/base" source="1.5" target="1.5" sourcepath="${drjava-src}"
debug="on" optimize="off" deprecation="on" includeAntRuntime="no" fork="yes">-->
<!-- (Have to specify additional explicit srcdirs - see below) -->
<javac destdir="classes/base" source="1.5" target="1.5" sourcepath="${drjava-src}"
debug="on" optimize="off" deprecation="on" includeAntRuntime="no" fork="yes">
<src>
<pathelement location="src" />
<!-- These classes won't automatically compile, because they aren't in files matching their name -->
<pathelement location="${drjava-src}/edu/rice/cs/util/sexp" />
</src>
<classpath>
<fileset refid="libs" />
<fileset refid="eclipse-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>
<mkdir dir="classes/test" /> <!-- May be deleted by the previous move -->
<move todir="classes/test">
<fileset dir="classes/base">
<include name="**/*Test.class" />
<include name="**/*Test$*.class" />
<include name="**/*TestCase.class" />
<include name="**/*TestCase$*.class" />
<!-- Additional test classes should be listed here -->
</fileset>
</move>
</target>
<!-- Matches base class files that should be RMI compiled. Search is relative to "classes/base". -->
<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" />
<include name="edu/rice/cs/util/newjvm/RemoteClassLoader.class" />
<!-- Additional base RMI classes should be listed here -->
</patternset>
<!-- Matches test class files that should be RMI compiled. Search is relative to "classes/test". -->
<patternset id="rmi-test-classes">
<exclude name="**" />
<!-- Additional test RMI classes should be listed here -->
</patternset>
<!-- 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" unless="rmi-classes-uptodate">
<echo message="Compiling RMI classes" />
<rmic base="classes/base" includeAntRuntime="no">
<patternset refid="rmi-base-classes" />
<classpath>
<fileset refid="libs" />
<pathelement location="classes/base" />
</classpath>
</rmic>
<rmic base="classes/test" includeAntRuntime="no">
<patternset refid="rmi-test-classes" />
<classpath>
<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">
<include name="**/LICENSE" />
<include name="**/README" />
<include name="**/*.gif" />
<include name="**/*.png" />
<include name="**/*.jpg" />
<include name="**/*.jpeg" />
<include name="**/*.properties" />
<!-- Additional resource files should be listed here -->
</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, assert-eclipse-exists"
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="${clover-jar}" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
<fileset refid="eclipse-libs" />
</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="${clover-jar}" />
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
<pathelement location="classes/test-14" />
<fileset refid="eclipse-libs" />
</path>
</pathconvert>
<retroweaver srcdir="classes/test" destdir="classes/test-14" target="1.4" verify="yes"
classpath="${retroweaver-test-classpath}" />
<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"
description="Run all 5.0 tests under Java 5.0 (after compiling); use -Dtest-spec=... to filter">
<antcall target="iterate-tests">
<param name="do-test-target" value="do-test-15" />
</antcall>
</target>
<target name="test-14" depends="compile-14"
description="Run all 1.4 tests under Java 1.4 (after compiling); use -Dtest-spec=... to filter">
<antcall target="iterate-tests">
<param name="do-test-target" value="do-test-14" />
</antcall>
</target>
<target name="test-14-in-15" depends="compile-14, assert-15"
description="Run all 1.4 tests under Java 5.0 (after compiling); use -Dtest-spec=... to filter">
<antcall target="iterate-tests">
<param name="do-test-target" value="do-test-14-in-15" />
</antcall>
</target>
<target name="iterate-tests">
<if>
<equals arg1="${test-spec}" arg2="" />
<then>
<limit minutes="${test-timeout}" failonerror="true">
<antcall target="${do-test-target}">
<param name="test-filter-string" value="" />
</antcall>
</limit>
</then>
<else>
<for list="${test-spec}" param="test-filter-string-attribute">
<sequential>
<limit minutes="${test-timeout}" failonerror="true">
<antcall target="${do-test-target}">
<param name="test-filter-string" value="@{test-filter-string-attribute}" />
</antcall>
</limit>
</sequential>
</for>
</else>
</if>
</target>
<selector id="tests-to-run">
<and>
<filename name="**/*${test-filter-string}*/**" />
<filename name="**/*Test.class" />
</and>
</selector>
<target name="do-test-15" depends="assert-eclipse-exists, assert-15">
<echo message="Running all 5.0 tests matching '${test-filter-string}' under Java 5.0" />
<junit haltonfailure="yes" fork="yes" forkmode="perTest" maxmemory="256M" dir="${basedir}">
<classpath>
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="${clover-jar}" />
<pathelement location="classes/test" />
<pathelement location="classes/base" />
<pathelement location="classes/lib" />
<fileset refid="eclipse-libs" />
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="classes/test">
<selector refid="tests-to-run" />
</fileset>
</batchtest>
</junit>
</target>
<target name="do-test-14" depends="resolve-java14-exec, assert-eclipse-exists">
<echo message="Running all 1.4 tests matching '${test-spec}' under Java 1.4" />
<junit haltonfailure="yes" fork="yes" forkmode="perTest" maxmemory="256M" jvm="${java14-exec}" dir="${basedir}">
<classpath>
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="${clover-jar}" />
<pathelement location="classes/test-14" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
<fileset refid="eclipse-libs" />
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="classes/test-14">
<selector refid="tests-to-run" />
</fileset>
</batchtest>
</junit>
</target>
<target name="do-test-14-in-15" depends="assert-eclipse-exists, assert-15">
<echo message="Running all 1.4 tests matching '${test-spec}' under Java 5.0" />
<junit haltonfailure="yes" fork="yes" forkmode="perTest" maxmemory="256M" dir="${basedir}">
<classpath>
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="${clover-jar}" />
<pathelement location="classes/test-14" />
<pathelement location="classes/base-14" />
<pathelement location="classes/lib-14" />
<fileset refid="eclipse-libs" />
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="classes/test-14">
<selector refid="tests-to-run" />
</fileset>
</batchtest>
</junit>
</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 5.0 jar file with all classes and libs (compiling first)">
<jar jarfile="drjava-eclipse-15.jar">
<manifest>
<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 5.0 jar file without any support libs (compiling first)">
<jar jarfile="drjava-eclipse-base-15.jar">
<manifest>
<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="drjava-eclipse.jar">
<manifest>
<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="drjava-eclipse-base-14.jar">
<manifest>
<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="assert-eclipse-exists, assert-drjava-src-exists, assert-15, resolve-version-tag"
description="Generate javadocs from the source folder">
<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" />
<echo message="NOTE: The 'generate-source' target of the drjava build script is assumed to" />
<echo message="have been run. Otherwise, you may encounter unexpected errors." />
<echo message="" />
<delete dir="docs/javadoc" />
<mkdir dir="docs/javadoc" />
<javadoc destdir="docs/javadoc" access="protected" Use="yes" Version="yes"
Author="yes" Windowtitle="${readable-project-name} API (${version-tag})">
<fileset dir="src" includes="**/*" />
<sourcepath>
<pathelement location="src" />
<pathelement location="${drjava-src}" />
</sourcepath>
<classpath>
<fileset refid="libs" />
<fileset refid="eclipse-libs" />
<pathelement location="lib/buildlib/junit.jar" />
</classpath>
<link href="http://java.sun.com/j2se/1.5/docs/api" />
<link href="http://junit.org/junit/javadoc/3.8.1" />
<link href="http://drjava.org/javadoc/drjava" />
<!-- TODO: Eclipse API link(s) -->
<!-- Additional external library APIs may be listed here -->
</javadoc>
</target>
<target name="clover" depends="clover-15" description="Shortcut for 'clover-15'">
</target>
<target name="clover-15" depends="clean, setup-clover, test-15, report-clover"
description="Generate a Clover test coverage report (using 'test-15')" />
<target name="clover-14" depends="clean, setup-clover, test-14, report-clover"
description="Generate a Clover test coverage report (using 'test-14')" />
<target name="clover-14-in-15" depends="clean, setup-clover, test-14-in-15, report-clover"
description="Generate a Clover test coverage report (using 'test-14-in-15')" />
<target name="report-clover" depends="resolve-version-tag">
<echo message="Generating Clover report" />
<clover-report>
<current outfile="docs/clover" title="${readable-project-name} Test Coverage (${version-tag})">
<format type="html" />
</current>
</clover-report>
<antcall target="clean-intermediate"> <!-- Remove instrumented class files -->
<param name="clean-can-fail" value="no" />
</antcall>
</target>
<target name="setup-clover" depends="assert-clover-jar-exists">
<extendclasspath path="${clover-jar}" />
<taskdef resource="clovertasks" classpath="${clover-jar}" />
<mkdir dir="cloverdb" />
<clover-setup initString="cloverdb/clover.db">
<files>
<exclude name="**/*Test.java" />
<exclude name="**/*TestCase.java" />
<!-- Additional test sources should be listed here -->
</files>
</clover-setup>
</target>
<!-- *************
Clean Targets
************* -->
<target name="clean" depends="clean-intermediate, clean-products"
description="Remove all build products; the result should match the intended Subversion contents">
</target>
<target name="clean-intermediate" unless="skip-clean">
<echo message="Deleting all intermediate build products" />
<delete dir="classes" failonerror="${clean-can-fail}" />
<delete dir="cloverdb" failonerror="${clean-can-fail}" />
<delete includeemptydirs="true" failonerror="${clean-can-fail}">
<fileset dir="${basedir}" defaultexcludes="no">
<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" />
<!-- Additional files to delete may be listed here -->
</fileset>
</delete>
</target>
<target name="clean-products" unless="skip-clean">
<echo message="Deleting all final build products" />
<delete dir="docs" failonerror="${clean-can-fail}" />
<delete includeemptydirs="true" failonerror="${clean-can-fail}">
<fileset dir="${basedir}" defaultexcludes="no">
<include name="*.jar" />
<include name="*.zip" />
<include name="*.tar.gz" />
<include name="${ant.project.name}-*" />
<include name="drjava-eclipse-*" />
</fileset>
</delete>
</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-intermediate"> <!-- Clean up after the latest build -->
<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="update, resolve-version-tag"
description="Copy the working copy to a new Subversion tag (after updating)">
<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" depends="update"
description="Copy the working copy to a new Subversion branch (after updating)">
<echo message="This will create a new branch from your working copy. If there are changes " />
<echo message="in your copy that have not been committed, you may want to do so first, " />
<echo message="so that there's a clear branch point for merging later." />
<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, tag, eclipse-plugin-zip, src-zip, javadoc-zip"
description="Generate all release files (after building)">
<delete dir="${version-tag}" />
</target>
<target name="eclipse-plugin-zip" depends="assert-jar-exists, resolve-version-tag">
<echo message="Creating drjava-eclipse-${eclipse-version}.zip" />
<property name="eclipse-plugin-dir" value="${version-tag}/plugin" />
<mkdir dir="${eclipse-plugin-dir}" />
<filter token="VERSION" value="${version-tag}" />
<filter token="ECLIPSE_VERSION" value="${eclipse-version}" />
<copy todir="${eclipse-plugin-dir}" filtering="yes" >
<fileset dir="packaging" excludes="**/*jar-goes-here" />
</copy>
<copy file="drjava-eclipse.jar" todir="${eclipse-plugin-dir}" />
<zip destfile="drjava-eclipse-${eclipse-version}.zip">
<zipfileset dir="${eclipse-plugin-dir}" prefix="edu.rice.cs.drjava_${eclipse-version}" />
</zip>
</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="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>
<!-- We don't include this in the standard release process, because we don't want to
include instrumented files in the release, and because Clover must be run on a
licensed machine -->
<target name="clover-zip" depends="clover-14-in-15, resolve-version-tag">
<echo message="Creating ${version-tag}-clover.zip" />
<zip destfile="${version-tag}-clover.zip">
<zipfileset dir="docs/clover" prefix="${version-tag}/clover" />
</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" />
<!-- Additional binary types may be added here -->
</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 "svn status" 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>
<!-- ***************************
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="assert-15">
<fail message="The specified target requires Ant to be run under Java 5.0 or later">
<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="drjava-eclipse.jar" />
<fail message="Can't find drjava-eclipse.jar" unless="jar-exists" />
</target>
<target name="assert-clover-jar-exists">
<available property="clover-jar-exists" file="${clover-jar}" />
<fail message="${clover-jar} does not exist" unless="clover-jar-exists" />
</target>
<target name="assert-drjava-src-exists">
<available property="drjava-src-exists" file="${drjava-src}" />
<fail message="${drjava-src} does not exist" unless="drjava-src-exists" />
</target>
<target name="assert-eclipse-exists">
<available property="eclipse-exists" file="${eclipse-home}" />
<fail message="${eclipse-home} does not exist" unless="eclipse-exists" />
</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="drjava-eclipse${tag-append}-${DSTAMP}-${TSTAMP}" />
</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>
</project>