<project name="JDB Team Maker" basedir="." default="release">
    
    <property environment="env"/>
    <property file="project.properties"/>

    <path id="groovy.class.path">
        <fileset dir="${env.GROOVY_HOME}/lib">
            <include name="*.jar"/>
        </fileset>
    </path>

    <taskdef name="groovyc"
        classpathref="groovy.class.path"
        classname="org.codehaus.groovy.ant.Groovyc"/>

    <target name="init">
        <mkdir dir="${build.dir}/classes"/>
    </target>

    <target name="clean">
        <delete dir="${build.dir}"/>
    </target>

    <target name="compile" depends="init">
        <groovyc
            srcdir="${src.dir}"
            destdir="${build.dir}/classes"
            classpathref="groovy.class.path"/>
    </target>

    <target name="increment-build-number">
        <propertyfile file="project.properties">
            <entry key="build.number" operation="+" default="0"
                value="1" type="int"/>
        </propertyfile>
    </target>

    <target name="build" depends="compile,increment-build-number">
        <unjar dest="${build.dir}/classes">
            <fileset dir="${env.GROOVY_HOME}/embeddable">
                <include name="*.jar"/>
            </fileset>
        </unjar>

        <jar
            destfile="${build.dir}/${app.name}-${app.version}.${build.number}.jar"
            basedir="${build.dir}/classes">
            <manifest>
                <attribute name="Main-Class" value="com.jdbernard.teammaker.TeamMaker"/>
            </manifest>
        </jar>
    </target>

    <target name="release" depends="build">
    </target>
</project>
