<?xml version="1.0"?>
<project name="BMTron" default="dist" basedir=".">
    
    <property name="version"  value="1.3.1"/>
    
    <property name="src"      value="src"/>
    <property name="build"    value="build"/>
    <property name="dist"     value="dist"/>
    <property name="res"      value="res"/>
    <property name="jar_file" value="bmtron.jar"/>
    
    <target name="init">
        <tstamp/>
        <mkdir dir="${build}"/>
    </target>
    
    <target name="compile" depends="init">
        <javac srcdir="${src}" destdir="${build}"
               source="1.3" target="1.1"
               deprecation="on" optimize="on" debug="off"/>
    </target>
    
    <target name="resources" depends="resource_builder">
        <mkdir dir="${dist}/skins"/>
        <java classname="ResourceBuilder">
            <classpath path="${res}"/>
            <arg value="BMTron Skin 1.3"/>
            <arg value="${basedir}/${dist}/skins/default.bin"/>
            <arg value="${basedir}/${res}/skins/default/"/>
        </java>
        
        <java classname="ResourceBuilder">
            <classpath path="${res}"/>
            <arg value="BMTron Skin 1.3"/>
            <arg value="${basedir}/${dist}/skins/yellow_on_black.bin"/>
            <arg value="${basedir}/${res}/skins/yellow_on_black/"/>
        </java>
    </target>
    
    <target name="resource_builder">
        <javac srcdir="${res}" source="1.3" target="1.1" 
               deprecation="on" optimize="on" debug="off"/>
    </target>    
    
    <target name="dist" depends="compile">
        <jar jarfile="${dist}/${jar_file}" manifest="${src}/Manifest.mf">
            <fileset dir="${build}" includes="**/*.class"/>
        </jar>
    </target>    
    
    <target name="package.tar.src" depends="init">
        <tar destfile="${dist}/bmtron-${version}-src.tar.gz"
             compression="gzip">
            <tarfileset dir="${basedir}"
                        prefix="bmtron-${version}">
                <exclude name="${build}/**"/>
                <exclude name="nbproject/**"/>
                <exclude name="${dist}/skins/**"/>
                <exclude name="${dist}/bmtron.jar"/>
                <exclude name="${dist}/bmtron-*.tar.gz"/>
                <exclude name="${dist}/bmtron-*.zip"/>
                <exclude name="${dist}/bmtron"/>
                <exclude name="${dist}/bmtron-skin*"/>
                <exclude name="${res}/*.class"/>
                <exclude name="${res}/skins/*/xcf/**"/>
                <exclude name=".*/**"/>
                <exclude name=".*"/>
            </tarfileset>
            <tarfileset dir="${basedir}"
                        prefix="bmtron-${version}"
                        mode="755">
                <include name="${dist}/bmtron"/>
                <include name="${dist}/bmtron-skin*"/>
            </tarfileset>
        </tar>
    </target>
    
    <target name="package.zip.bin" depends="dist,resources">
        <zip destfile="${dist}/bmtron-${version}.zip">
            <zipfileset dir="${dist}"
                        prefix="bmtron-${version}">
                <exclude name="bmtron-*.tar.gz"/>
                <exclude name="bmtron-*.zip"/>
                <exclude name="bmtron"/>
                <exclude name="bmtron-skin*"/>
            </zipfileset>
            <zipfileset dir="${dist}"
                        prefix="bmtron-${version}"
                        filemode="755">
                <include name="bmtron"/>
            </zipfileset>
        </zip>
    </target>
    
    <target name="package" depends="package.tar.src,package.zip.bin"/>
    
    <target name="clean">
        <delete>
            <fileset dir="${build}" includes="**/*.class"/>
        </delete>
        <delete file="${dist}/${jar_file}"/>
    </target>
    
    <target name="clean_resources">
        <delete>
            <fileset dir="${res}" includes="*.class"/>
        </delete>
        <delete file="${dist}/skins/default.bin"/>
        <delete file="${dist}/skins/yellow_on_black.bin"/>
    </target>
    
</project>
