<!-- (jEdit options) :folding=explicit:collapseFolds=1: -->
<project name="driftwood" default="dist" basedir=".">
<description>Driftwood libraries by IWD</description>

<!-- global properties that we always want defined {{{ -->
<property name="src"        location="src"/>
<property name="resource"   location="resource"/>
<property name="build"      location="build"/>
<property name="dist"       location="dist"/>
<!-- Version control: creates timestamp, updates ${buildnum}, loads ${version} -->
<target name="init">
    <tstamp>
        <format property="DSTAMP_SIX" pattern="yyMMdd"/>
    </tstamp>
    <propertyfile file="${resource}/${ant.project.name}/buildnum.props">
        <entry key="buildnum" value="${DSTAMP}.${TSTAMP}"/>
    </propertyfile>
    <property file="${resource}/${ant.project.name}/buildnum.props"/>
    <property file="${resource}/${ant.project.name}/version.props"/>
</target>
<!-- Defines properties needed to use SCP -->
<target name="init-scp">
    <property file="../lib/scp.props"/>
</target>
<!-- }}} -->

<!-- build, compile {{{ -->
<!-- Bundles up all needed class and resource files into a JAR -->
<target name="build" description="Build class files" depends="init,compile">
    <echo message="Version ${version}"/>
    <echo message="Build # ${buildnum}"/>
    <jar jarfile="${ant.project.name}.jar" index="false">
        <fileset dir="${build}"/>
        <fileset dir="${resource}"/>
    </jar>
</target>

<!-- Compiles all .java files for this package -->
<target name="compile" depends="init">
    <mkdir dir="${build}"/>
    <javac srcdir="${src}"
           destdir="${build}"
           includes="**/*.java"
           excludes="**/old/"
           deprecation="off"
           debug="on" debuglevel="lines,source"
           target="1.7" source="1.7">
    </javac>
</target>
<!-- }}} -->

<!-- dist, dist-src, dist-exe {{{ -->
<!-- Makes .zip files from the ${dist} directory -->
<target name="dist" description="Generate the distributions" depends="init,clean,build,dist-src,dist-exe">
    <zip destfile="${dist}/${ant.project.name}-${version}-src.zip">
         <zipfileset dir="${dist}" includes="${ant.project.name}/"/>
    </zip>
    <zip basedir="${dist}"
         destfile="${dist}/${ant.project.name}-${version}.zip"
         includes="${ant.project.name}-${version}/"/>
</target>

<!-- Makes the source code distribution -->
<target name="dist-src" depends="init">
    <mkdir dir="${dist}/${ant.project.name}-${version}-src"/>
    <copy todir="${dist}/${ant.project.name}-${version}-src" preservelastmodified="true">
        <fileset dir="${basedir}">
            <exclude name="build/"/>
            <exclude name="dist/"/>
            <exclude name="**/old/"/>
            <exclude name="doc/nodist/"/>
        </fileset>
    </copy>
    <mkdir dir="${dist}/${ant.project.name}"/>
    <copy todir="${dist}/${ant.project.name}" preservelastmodified="true">
        <fileset dir="${basedir}">
            <exclude name="build/"/>
            <exclude name="dist/"/>
            <exclude name="**/old/"/>
            <exclude name="doc/nodist/"/>
        </fileset>
    </copy>
</target>

<!-- Makes the end-user distribution -->
<target name="dist-exe" depends="init,build">
    <mkdir dir="${dist}/${ant.project.name}-${version}"/>
    <copy todir="${dist}/${ant.project.name}-${version}" preservelastmodified="true">
        <fileset dir="${basedir}">
            <include name="${ant.project.name}.jar"/>
            <include name="README*"/>
            <include name="LICENSE*"/>
            <include name="doc/"/>
            <exclude name="doc/work/"/>
            <exclude name="doc/nodist/"/>
        </fileset>
    </copy>
</target>
<!-- }}} -->

<!-- clean, backup {{{ -->
<!-- Removes products of compilation -->
<target name="clean" description="Clean up build/ and dist/">
    <delete dir="${dist}"/>
    <delete dir="${build}"/>
    <delete file="${ant.project.name}.jar"/>
</target>

<!-- Bundles this code and saves it locally and remotely - simple version control -->
<target name="backup" depends="init,clean,init-scp" description="Backs up this project on IWD's machine">
    <tstamp/>
    <mkdir dir="${user.home}/ark/old-versions/${ant.project.name}"/>
    <jar jarfile="${user.home}/ark/old-versions/${ant.project.name}/${ant.project.name}-${version}.${buildnum}.jar" index="true">
        <fileset dir="${basedir}"/>
    </jar>
    <scp file="${user.home}/ark/old-versions/${ant.project.name}/${ant.project.name}-${version}.${buildnum}.jar"
        todir="${scp.backup.username}@${scp.backup.hostname}:${scp.backup.path}/${ant.project.name}-${version}.${buildnum}.jar"
        password="${scp.backup.password}" failonerror="true"/>
</target>
<!-- }}} -->
</project>
