<project name="Clover_Tutorial" default="test" basedir=".">

    <property name="build.classes" location="build/classes"/>
    <property name="build.testclasses" location="build/testclasses"/>
    <property name="build.testresults" location="build/testresults"/>

    <property name="junit.jar" location="lib/junit-4.12.jar"/>
    <property name="hamcrest.jar" location="lib/hamcrest-core-1.3.jar"/>
    <property name="groovy-all.jar" location="lib/groovy-all-2.4.15.jar"/>
    <!-- Ensure you have copied clover.jar to this location -->
    <property name="clover.jar" location="${user.home}/.ant/lib/clover.jar"/>

    <path id="build.classpath">
        <pathelement location="${clover.jar}"/>
        <pathelement location="${groovy-all.jar}"/>
        <pathelement location="${build.classes}"/>
    </path>

    <path id="testbuild.classpath">
        <path refid="build.classpath"/>
        <pathelement location="${junit.jar}"/>
        <pathelement location="${hamcrest.jar}"/>
        <pathelement location="${build.testclasses}"/>
    </path>

    <taskdef resource="cloverlib.xml"/>

    <target name="compile">
        <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="${groovy-all.jar}"/>

        <mkdir dir="${build.classes}"/>
        <groovyc destdir="${build.classes}">
            <src path="src/main/java"/>
            <src path="src/main/groovy"/>
            <javac classpathref="build.classpath"/>
        </groovyc>

        <mkdir dir="${build.testclasses}"/>
        <groovyc destdir="${build.testclasses}">
            <src path="src/test/java"/>
            <src path="src/test/groovy"/>
            <javac classpathref="testbuild.classpath"/>
        </groovyc>
    </target>

    <target name="test" depends="compile">
        <mkdir dir="${build.testresults}"/>
        <junit fork="yes" printsummary="true" showoutput="true">
            <classpath refid="testbuild.classpath"/>
            <formatter type="xml"/>
            <batchtest fork="yes" todir="${build.testresults}">
                <fileset dir="${build.testclasses}" includes="**/*Test.*"/>
            </batchtest>
        </junit>
    </target>

    <target name="clean">
        <delete dir="build"/>
    </target>

    <!-- Clover targets -->

    <target name="with.clover">
        <clover-setup/>
    </target>

    <target name="clover.snapshot">
        <clover-snapshot/>
    </target>

    <target name="clover.report">
        <clover-html-report outdir="build/clover_html" title="Tutorial"/>
    </target>

    <target name="clover.all" depends="with.clover, test, clover.snapshot, clover.report"
            description="Runs a build with Clover and generates a Clover HTML report">
    </target>

</project>
