<?xml version="1.0" ?>
<!--
Shade build file.
ant setup Initialize Shade environment.
ant compile Run to compile the code.
ant run Run to launch Shade
ant webstart Deploy shade as a webstart.
ant clean Removes products of the build process, etc.
Alex Schearer
-->
<project name="Shade" default="compile">
<property name="src.dir" value="src" />
<property name="res.dir" value="res" />
<property name="lib.dir" value="lib" />
<property name="obj.dir" value="bin" />
<property name="target.dir" value="." />
<property name="script.dir" value="script" />
<property name="webstart.dir" value="${target.dir}/webstart" />
<!-- Set up the Shade environment including preparing the natives. -->
<target name="setup" depends="check-setup" unless="setup.exists">
<delete dir="${lib.dir}/natives" />
<mkdir dir="${lib.dir}/natives" />
<unzip src="${lib.dir}/natives-win32.jar" dest="${lib.dir}/natives" />
<unzip src="${lib.dir}/natives-mac.jar" dest="${lib.dir}/natives" />
<unzip src="${lib.dir}/natives-linux.jar" dest="${lib.dir}/natives" />
</target>
<!-- Compile and archive Shade. -->
<target name="jar">
<antcall target="compile" />
<antcall target="archive" />
</target>
<!-- Run Shade. -->
<target name="run" depends="setup,compile">
<java fork="true" classname="com.shade.Shade">
<classpath>
<pathelement path="${obj.dir}" />
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</classpath>
<jvmarg value="-Djava.library.path=lib/natives" />
</java>
</target>
<!-- Clean up the environment. -->
<target name="clean">
<delete includeEmptyDirs="true">
<fileset dir="${obj.dir}" includes="**/*" defaultExcludes="no" />
</delete>
<delete file="${target.dir}/shade.jar" />
<delete>
<fileset dir="${src.dir}" includes="**/*.orig" />
</delete>
<delete>
<fileset dir="." defaultExcludes="no">
<include name="**/*.DS_Store"/>
</fileset>
</delete>
<delete dir="${webstart.dir}" />
</target>
<target name="format">
<exec executable="${script.dir}/astyle">
<arg value="-p" />
<arg value="-r" />
<arg value="-c" />
<arg value="--style=java" />
<arg value="${src.dir}/*" />
</exec>
</target>
<!-- Create a webstart directory in order to deploy Shade. -->
<target name="webstart" depends="jar">
<input message="Web server url:" addproperty="codebase" />
<delete dir="${webstart.dir}" />
<mkdir dir="${webstart.dir}" />
<copy file="${script.dir}/htaccess" tofile="${webstart.dir}/.htaccess" />
<copy file="${target.dir}/shade.jar" tofile="${webstart.dir}/shade.jar" />
<copy file="${target.dir}/lib/crash.jar" tofile="${webstart.dir}/crash.jar" />
<copy file="${target.dir}/lib/slickfx.jar" tofile="${webstart.dir}/slickfx.jar" />
<copy file="${target.dir}/lib/BareBonesBrowserLaunch.jar" tofile="${webstart.dir}/BareBonesBrowserLaunch.jar" />
<copy file="${script.dir}/template.jnlp" tofile="${webstart.dir}/shade.jnlp">
<filterchain>
<replacetokens>
<token key="codebase" value="${codebase}" />
</replacetokens>
</filterchain>
</copy>
<antcall target="signjar" />
</target>
<!-- Determines whether setup has been run. -->
<target name="check-setup">
<condition property="setup.exists">
<available file="${lib.dir}/natives" type="dir" />
</condition>
</target>
<!-- Determines whether a keystore exists. -->
<target name="check-keystore">
<input message="Username:" addproperty="keystore.alias" />
<input message="Password:" addproperty="keystore.pass" />
<condition property="keystore.exists">
<available file="${target.dir}/${keystore.alias}.ks" type="file" />
</condition>
</target>
<!-- Create a key store. -->
<target name="keystore" depends="check-keystore" unless="keystore.exists">
<input message="Full Name:" addproperty="keystore.name" />
<input message="Company:" addproperty="keystore.company" />
<genkey keystore="${target.dir}/${keystore.alias}.ks"
alias="${keystore.alias}"
storepass="${keystore.pass}">
<dname>
<param name="CN" value="${keystore.name}" />
<param name="OU" value="${keystore.company}" />
<param name="O" value="" />
<param name="C" value=""/>
</dname>
</genkey>
</target>
<!-- Sign's webstart/shade.jar for deployment. -->
<target name="signjar" depends="keystore">
<signjar jar="${webstart.dir}/shade.jar"
keystore="${target.dir}/${keystore.alias}.ks"
storepass="${keystore.pass}"
alias="${keystore.alias}" />
<signjar jar="${webstart.dir}/crash.jar"
keystore="${target.dir}/${keystore.alias}.ks"
storepass="${keystore.pass}"
alias="${keystore.alias}" />
<signjar jar="${webstart.dir}/slickfx.jar"
keystore="${target.dir}/${keystore.alias}.ks"
storepass="${keystore.pass}"
alias="${keystore.alias}" />
<signjar jar="${webstart.dir}/BareBonesBrowserLaunch.jar"
keystore="${target.dir}/${keystore.alias}.ks"
storepass="${keystore.pass}"
alias="${keystore.alias}" />
</target>
<!-- Compile the code put results into obj.dir. -->
<target name="compile">
<mkdir dir="${obj.dir}" />
<javac destdir="${obj.dir}" debug="on">
<src path="${src.dir}" />
<classpath>
<pathelement path="${lib.dir}/slick.jar" />
<pathelement path="${lib.dir}/lwjgl.jar" />
<pathelement path="${lib.dir}/crash.jar" />
<pathelement path="${lib.dir}/slickfx.jar" />
<pathelement path="${lib.dir}/ibxm.jar" />
<pathelement path="${lib.dir}/BareBonesBrowserLaunch.jar" />
</classpath>
</javac>
<copy todir="${obj.dir}">
<fileset dir="${res.dir}" />
</copy>
</target>
<!-- Jar compiled code and place result into target.dir. -->
<target name="archive">
<jar destfile="${target.dir}/shade.jar" manifest="${script.dir}/manifest.txt">
<fileset dir="${obj.dir}" />
</jar>
</target>
</project>