<?xml version="1.0"?>

<project name="clubadministration" basedir="." default="usage">

    <property name="src.dir" value="src"/>
    <property name="classes.dir" value="classes"/>
    <property name="name" value="ClubAdministration"/>
    <property name="res.dir" value="resources"/>
    <property name="conf.dir" value="conf"/>
    <property name="jsp.dir" value="jsp"/>

    <path id="master-classpath">
        <fileset dir="../lib">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${appserver.home}/common/lib">
            <include name="servlet*.jar"/>
        </fileset>
        <fileset dir="${mule.home}/lib">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${mule.home}/lib/opt">
            <include name="*.jar"/>
        </fileset>
        <pathelement path="${classes.dir}"/>
    </path>

    <target name="usage">
        <echo message=""/>
        <echo message="${name} build file"/>
        <echo message="-----------------------------------"/>
        <echo message=""/>
        <echo message="Available targets are:"/>
        <echo message=""/>
        <echo message="build     --> Build the application"/>
        <echo message="deploy    --> Deploy application as directory"/>
        <echo message=""/>
    </target>

    <target name="build" description="Compile main source tree java files">
        <mkdir dir="${classes.dir}"/>
        <javac destdir="${classes.dir}" target="1.3" debug="true"
               deprecation="false" optimize="false" failonerror="true">
            <src path="${src.dir}"/>
            <classpath refid="master-classpath"/>
        </javac>
    </target>

    <target name="deploy" depends="build" description="Deploy application">
        <!-- copy the classes -->
        <copy todir="${deploy.path}/${name}/WEB-INF/classes" preservelastmodified="true">
            <fileset dir="${classes.dir}">
                <include name="**/*.*"/>
            </fileset>
        </copy>
        <!-- copy the resources -->
        <copy todir="${deploy.path}/${name}/WEB-INF/classes" preservelastmodified="true">
            <fileset dir="${res.dir}">
                <include name="**/*.*"/>
            </fileset>
        </copy>
        <!-- Copy libraries -->
        <copy todir="${deploy.path}/${name}/WEB-INF/lib" preservelastmodified="true">
            <fileset dir="../lib">
              <include name="*.jar"/>
            </fileset>
            <fileset dir="${mule.home}/lib">
              <include name="*.jar"/>
            </fileset>
            <fileset dir="${mule.home}/lib/opt">
              <include name="log4j-1.2.8.jar"/>
              <include name="axis-*.jar"/>
            </fileset>
        </copy>
        <!-- copy the configuration files for the webapp -->
        <copy todir="${deploy.path}/${name}/WEB-INF/" preservelastmodified="true">
            <fileset dir="${conf.dir}">
                <include name="**/*.*"/>
            </fileset>
        </copy>
        <!-- copy the JSP-Pages -->
        <copy todir="${deploy.path}/${name}/" preservelastmodified="true">
            <fileset dir="${jsp.dir}">
                <include name="**/*.*"/>
            </fileset>
        </copy>
    </target>

</project>