<?xml version="1.0"?>

<!--
    $RCSfile$
    $Revision$
    $Date$
-->

<project name="WebChat" default="all" basedir="..">

    <property file="${basedir}/build/webchat-build.properties" />
    <property name="smack.home" value="${basedir}/../../../smack" />
    <property name="compile.dir" value="${basedir}/build/temp" />
    <property name="jar.dest.dir" value="${basedir}/build/WEB-INF/lib" />
    <property name="jar.name" value="webchat" />
    <property name="war.dest.dir" value="${basedir}" />
    <property name="war.name" value="webchat" />


    <path id="dependencies">
        <!-- build jars -->
        <fileset dir="${smack.home}" includes="smack.jar" />
        <fileset dir="${basedir}/build/lib" includes="*.jar" />
    </path>


    <patternset id="web.filetypes">
        <include name="**/*.jsp" />
        <include name="**/*.js" />
        <include name="**/*.html" />
        <include name="**/*.gif" />
        <include name="**/*.css" />
    </patternset>


    <target name="init">
        <mkdir dir="${compile.dir}" />
        <mkdir dir="${jar.dest.dir}" />
        <!-- call smack jar process -->
        <ant antfile="build/build.xml" dir="${smack.home}" target="jar" inheritAll="false" />
    </target>


    <target name="clean">
        <delete dir="${compile.dir}" />
        <delete dir="${jar.dest.dir}" />
        <!-- call smack jar process -->
        <ant antfile="build/build.xml" dir="${smack.home}" target="clean" inheritAll="false" />
    </target>


    <target name="compile" depends="init">
        <javac
            destdir="${compile.dir}"
            includeAntRuntime="no"
            debug="on"
            classpathref="dependencies"
        >
            <src path="${basedir}/source/java" />
        </javac>
    </target>


    <target name="jar" depends="compile">
        <jar destfile="${jar.dest.dir}/${jar.name}.jar"
            basedir="${compile.dir}"
            includes="**/*.class"
         />
    </target>


    <target name="war" depends="jar">
        <war warfile="${war.dest.dir}/${war.name}.war"
            webxml="${basedir}/source/config/WEB-INF/web.xml"
        >
            <lib dir="${jar.dest.dir}" includes="*.jar" />
            <lib dir="${smack.home}" includes="smack.jar" />
            <zipfileset dir="${basedir}/source/web">
                <patternset refid="web.filetypes" />
            </zipfileset>
        </war>
    </target>


    <target name="deploywar" depends="war">
        <copy todir="${deploy.war.dir}" overwrite="${overwrite}">
            <fileset dir="${war.dest.dir}" includes="${war.name}.war" />
        </copy>
    </target>

</project>