<project default="mule:war"
    xmlns:j="jelly:core"
    xmlns:u="jelly:util"
    xmlns:ant="jelly:ant"
    xmlns:maven="jelly:maven">

    <!-- this goal should be run from the distribution and assumes the distribution
    directory structure is present -->
    <goal name="mule:war">
        <echo>Building Mule Samples war</echo>
        <!-- copy libs -->
        <copy todir="webapp/WEB-INF/lib">
            <fileset dir="../../lib">
                <include name="*.jar"/>
            </fileset>
        </copy>
        <copy todir="webapp/WEB-INF/lib">
            <fileset dir="../../lib/opt">
                <include name="*.jar"/>
            </fileset>
        </copy>

        <copy todir="webapp/WEB-INF/classes">
            <fileset dir="../hello/classes"/>
        </copy>
        <copy todir="webapp/WEB-INF/classes">
            <fileset dir="../loanbroker/classes"/>
        </copy>
        <copy todir="webapp/WEB-INF/classes">
            <fileset dir="../errorhandler/classes"/>
        </copy>

        <copy todir="webapp/WEB-INF/classes">
            <fileset dir="../stockquote/classes"/>
        </copy>


        <copy todir="webapp/WEB-INF/classes" file="../stockquote/conf/stock.xsl"/>


        <!-- create the war -->
        <zip zipfile="mule.war">
            <zipfileset dir="webapp"/>
        </zip>
    </goal>

    <!-- This is the Mule distribution build target and can be ignored by users -->
    <goal name="distro" prereqs="setvars,test">
        <j:set var="mule.samples.dist.dir" value="../target/release/samples/mule-webapp"/>
        <echo>WebApp dist dir is ${mule.samples.dist.dir}</echo>
        <mkdir dir="${mule.samples.dist.dir}"/>
        <mkdir dir="${mule.samples.dist.dir}/webapp/WEB-INF/lib"/>

        <copy todir="${mule.samples.dist.dir}" file="maven.xml"/>
        <copy todir="${mule.samples.dist.dir}/webapp/WEB-INF/classes" file="../../mule/src/conf/log4j.properties"/>

        <copy todir="${mule.samples.dist.dir}/webapp">
            <fileset dir="webapp">
                <include name="**/*.xml"/>
                <include name="**/*.jsp"/>
                <include name="**/*.html"/>
                <include name="**/*.gif"/>
            </fileset>
        </copy>

        <echo>Copying webapp classes from ${maven.build.dir}/classes to ${mule.samples.dist.dir}/webapp/WEB-INF/classes</echo>
        <copy todir="${mule.samples.dist.dir}/webapp/WEB-INF/classes">
            <fileset dir="${maven.build.dir}/classes"/>
        </copy>
    </goal>
</project>