<!--
  $Id: build.xml,v 1.1 2006/07/08 21:13:52 larry Exp $
-->

<project name="Sparkline Tag Library $Revision: 1.1 $" default="package" basedir=".">

  <property name="app.name"      value="spark"/>

  <property name="catalina.home" value="/opt/tomcat"/>
  <property name="dist.home"     value="${basedir}/dist"/>
  <property name="src.home"      value="${basedir}/src"/>
  <property name="web.home"      value="${basedir}/web"/>
  <property name="conf.home"     value="${basedir}/conf" />
  <property name="lib.home"      value="${basedir}/lib"/>

  <property name="build.home"    value="${basedir}/build"/>

  <property file="${user.home}/build.properties"/>
  <property file="build.properties"/>

  <property name="compile.debug"       value="true"/>
  <property name="compile.deprecation" value="false"/>
  <property name="compile.optimize"    value="true"/>
  <property name="javac.args"          value="-Xlint:-unchecked" />


    <path id="compile.classpath">
        <fileset dir="${lib.home}">
            <include name="*.jar" />
        </fileset>

        <!-- Include all elements that Tomcat exposes to applications -->
        <pathelement location="${catalina.home}/common/classes" />
        <fileset dir="${catalina.home}/common/endorsed">
            <include name="*.jar" />
        </fileset>
        <fileset dir="${catalina.home}/common/lib">
            <include name="*.jar" />
        </fileset>
        <pathelement location="${catalina.home}/shared/classes" />
        <fileset dir="${catalina.home}/shared/lib">
            <include name="*.jar" />
        </fileset>

    </path>

    <target name="clean" description="Delete old build and dist directories">
        <delete dir="${build.home}" />
        <delete dir="${dist.home}" />

        <!-- delete emacs backup files -->
        <delete>
            <fileset dir="." defaultexcludes="false" includes="**/*~" />
        </delete>

        <delete dir="${build.home}/jar"/>
        <delete file="${build.home}/${app.name}.jar"/>
    </target>

    <target name="init">
        <tstamp/>
    </target>

    <target name="prepare" description="Creates the Web Application's war directory" depends="init">
        <echo message="Creating ${app.name}'s jar directory ..."/>
	<mkdir dir="${build.home}/jar" />
        <mkdir dir="${build.home}/jar/META-INF" />
    </target>

    <target name="build" description="Builds the Web Application" depends="prepare">
        <echo message="Building ${app.name} ..."/>

        <javac srcdir="${src.home}" destdir="${build.home}/jar">
            <include name="**/*.java"/>
            <classpath refid="compile.classpath"/>
        </javac>

        <copy todir="${build.home}/jar/META-INF">
            <fileset dir="${src.home}/META-INF">
                <include name="spark.tld"/>
            </fileset>
        </copy>
    </target>

    <target name="package" description="Packages the Web Application's web archive file" depends="build">
        <echo message="Packaging ${app.name}'s jar file ..."/>
        <delete file="${build.home}/${app.name}.jar"/>
        <jar jarfile="${build.home}/${app.name}.jar"
             manifest="${src.home}/manifest.mf"
        >
            <fileset dir="${build.home}/jar" includes="**"/>
        </jar>
    </target>
</project>
