<?xml version="1.0" encoding="UTF-8"?>
<project name="Zallery" >

    <!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->

    <!--common properties-->
    <property name="gitRoot" value="." />
    <property name="srcDir" value="${gitRoot}/src" />
    <property name="libDir" value="${gitRoot}/lib" />
    <property name="libExpDir" value="${gitRoot}/WebContent/WEB-INF/lib" />
    <property name="outputRoot" value="${gitRoot}/build" />
    <property name="buildDir" value="${outputRoot}/production" />
    <property name="releaseDir" value="${outputRoot}/release" />
    <property name="deployPath" value="/var/lib/tomcat7/webapps/Zallery.war" />

    <!-- Deployment properties -->
    <property name="tomcat.url" value="http://localhost:8080/manager/text" />
    <property name="tomcat.user" value="" />
    <property name="tomcat.pass" value="" />
    <property name="catalina.home" value="/usr/shared/tomcat7"/>

    <!--define standard arguments for javac-->
    <presetdef name="javac">
        <javac includeantruntime="false" />
    </presetdef>

    <!-- ________________________ CLASSPATHS ________________________ -->

    <!--classpath included when building-->
    <path id="classpath.build">
        <fileset dir="${libDir}">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${libExpDir}">
            <include name="**/*.jar" />
        </fileset>
        <pathelement location="${buildDir}" />
    </path>

    <!-- ________________________ EXECUTION TARGETS ________________________ -->



    <!-- ________________________ BUILD TARGETS ________________________ -->

    <!--clean all build paths-->
    <target name="clean">
        <delete includeemptydirs="true" failonerror="false">
            <fileset dir="${outputRoot}" includes="**/*" />
        </delete>
    </target>

    <!--build product code-->
    <target name="build">
        <mkdir dir="${buildDir}" />
        <get src="http://ci.koc.se/jenkins/job/Zutil/lastSuccessfulBuild/artifact/build/release/Zutil.jar" dest="${libExpDir}" verbose="true" usetimestamp="true"/>
        <javac target="1.7" srcdir="${srcDir}" destdir="${buildDir}" debug="yes" debugLevel="lines,vars,source">
            <classpath refid="classpath.build" />
            <include name="**/*.java" />
        </javac>
    </target>

    <target name="package" depends="build">
        <war destfile="${releaseDir}/Zallery.war" webxml="WebContent/WEB-INF/web.xml">
            <fileset dir="WebContent" />
            <!-- <fileset dir="${srcDir}"/> -->
            <lib dir="WebContent/WEB-INF/lib" />
            <classes dir="${buildDir}" />
        </war>
    </target>

    <target name="deploy" depends="package">
        <import file="${catalina.home}/bin/catalina-tasks.xml"/>
        <deploy url="${tomcat.url}"
                username="${tomcat.user}"
                password="${tomcat.pass}"
                path="/zallery"
                update="true"
                war="file:${releaseDir}/Zallery.war" />
    </target>

</project>
