<!-- ANT Build Script for the "bsf" Custom Tag Library -->
<!-- $Id: build.xml,v 1.3 2000/12/08 02:50:01 horwat Exp $ -->
<project name="bsf" default="main" basedir=".">

  <!-- ********************** Properties setup ********************* -->

  <property environment="env"/>
  <property file="../build.properties"/>

  <!-- ********************** Check Required Components *************** -->

  <target name="checkRequiredComponents">
    
    <available classname="org.apache.xerces.framework.XMLParser"
               property="xerces.present"/>
    <antcall target="checkXerces"/>
    
    <available classname="org.apache.xalan.xslt.Stylesheet"
               property="xalan.present"/>
    <antcall target="checkXalan"/>
    
    <available property="bsf.present" 
               classname="com.ibm.bsf.BSFManager" />
    <available property="bsf.present" 
               file="${bsf.jar}" />
    <antcall target="checkBsf"/>
    
  </target>
      
  <target name="checkXerces" unless="xerces.present">
    <fail message="xerces was not found. please install xerces.jar in the lib directory of your ant home, or add xerces.jar to your classpath"/>
  </target>
  
  <target name="checkXalan" unless="xalan.present">
    <fail message="xalan was not found. please install xalan.jar in the lib directory of your ant home, or add xalan.jar to your classpath"/>
  </target>

  <target name="checkBsf" unless="bsf.present">
    <fail message="bsf was not found. please verify that the BSF_JAR environment variable points to the bsf.jar file. download bsf from oss.software.ibm.com/developerworks/projects/bsf if necessary." />
  </target>
  

  <!-- ********************** Destination Preparation ********************* -->

  <target name="prepare" depends="checkRequiredComponents">
  
    <!-- Set up build directories -->
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.doc}"/>
    <mkdir dir="${build.doc}/WEB-INF"/>
    <mkdir dir="${build.doc}/WEB-INF/classes"/>
    <mkdir dir="${build.doc}/WEB-INF/lib"/>
    <mkdir dir="${build.examples}"/>
    <mkdir dir="${build.examples}/WEB-INF"/>
    <mkdir dir="${build.examples}/WEB-INF/classes"/>
    <mkdir dir="${build.examples}/WEB-INF/lib"/>
    <mkdir dir="${build.library}"/>
    <mkdir dir="${build.library}/META-INF"/>
    <!-- Set up distribution directory -->
    <mkdir dir="${dist.dir}"/>
    <mkdir dir="${dist.dir}/${taglib.name}"/>
  </target>


  <!-- **************** Compile Tag Library Components ******************** -->

  <!-- Compile the documentation application -->
  <target name="documentation" depends="prepare">
    <copy todir="${build.doc}/WEB-INF">
      <fileset dir="${doc.src}/conf"/>
    </copy>
    <style   basedir="${doc.src}/web" destdir="${build.doc}"
      extension=".html" style="${taglibs.xsl}" includes="*.xml"/>
    <copy todir="${build.doc}">
      <fileset dir="${doc.src}/web">
        <include name="**/*.html"/>
      </fileset>
    </copy>
  </target>

  <!-- Compile the examples application -->
  <target name="examples" depends="library-dist">
    <copydir src="${examples.src}/conf" dest="${build.examples}/WEB-INF"/>
    <copydir src="${examples.src}/web"  dest="${build.examples}"/>
    <copyfile src="${dist.tld}"
              dest="${build.examples}/WEB-INF/${taglib.name}.tld"/>
    <copyfile src="${dist.library}"
              dest="${build.examples}/WEB-INF/lib/${taglib.name}.jar"/>
  </target>

  <!-- Compile the tag library itself -->
  <target name="library" depends="prepare">
    <copyfile src="${conf.src}/taglib.tld"
              dest="${build.library}/META-INF/taglib.tld"/>
    <javac srcdir="${library.src}" destdir="${build.library}"
           classpath="${servlet.jar};${bsf.jar}" debug="on"/>
  </target>

  <!-- Compile the library as well as the associated applications -->
  <target name="main" depends="library,documentation,examples"/>


  <!-- ******************* Create Distribution Files ********************** -->

  <!-- Create the documentation application WAR file -->
  <target name="documentation-dist" depends="documentation">
    <jar jarfile="${dist.doc}" basedir="${build.doc}"/>
  </target>

  <!-- Create the examples application WAR file -->
  <target name="examples-dist" depends="examples">
    <jar jarfile="${dist.examples}" basedir="${build.examples}"/>
  </target>

  <!-- Create the library distribution files -->
  <target name="library-dist" depends="library">
    <jar jarfile="${dist.library}" basedir="${build.library}"/>
    <copyfile src="${conf.src}/taglib.tld" dest="${dist.tld}"/>
  </target>

  <!-- Create the entire set of distribution files -->
  <target name="dist" depends="library-dist,examples-dist,documentation-dist"/>


  <!-- ************************ Utility Commands ************************** -->

  <!-- Delete output directories and files so we can build from scratch -->
  <target name="clean">
    <deltree dir="${build.doc}"/>
    <deltree dir="${build.examples}"/>
    <deltree dir="${build.library}"/>
    <deltree dir="${dist.dir}/${taglib.name}"/>
  </target>

</project>
