<project default="build" name="Ant2 script tasks" basedir="..">

  <property name="src.dir" value="src"/>
  <property name="lib.dir" value="lib"/>
  <property name="java.dir" value="${src.dir}/java"/>

  <property name="bin.dir" value="bin"/>
  <property name="dist.dir" value="dist"/>
  <property name="javadocs.dir" value="${dist.dir}/javadocs"/>
  <property name="distlib.dir" value="${dist.dir}/lib"/>
  
  <property name="debug" value="true"/>

  <property name="ant.package" value="org/apache/tools/ant"/>
  <property name="optional.package" value="${ant.package}/taskdefs/optional"/>
  <property name="optional.type.package" value="${ant.package}/types/optional"/>
  <property name="util.package" value="${ant.package}/util"/>
  <property name="regexp.package" value="${util.package}/regexp"/>

  
  <path id="classpath.script">
    <pathelement location="${distlib.dir}/init.jar"/>
    <fileset dir="${lib.dir}/antlib/script" includes="*.jar"/>
    <pathelement location="${distlib.dir}/common/common.jar"/>
  </path>

  <target name="check_bsf">
    <available property="bsf.present"
               classname="com.ibm.bsf.BSFManager"
               classpathref="classpath.script" />
  </target>
  
  <target name="nobsf" unless="bsf.present">
    <echo message="You must provide the bsf.jar library in the ${lib.dir}/antlib/script directory"/>
  </target>
  
  <target name="build" depends="check_bsf, nobsf" if="bsf.present">
    <mkdir dir="${bin.dir}/antlibs/script"/>
    <mkdir dir="${distlib.dir}/antlibs"/>
    <depend destdir="${bin.dir}/antlibs/script" srcdir="${java.dir}/antlibs/script">
      <classpath refid="classpath.script"/>
    </depend>
    <javac destdir="${bin.dir}/antlibs/script" srcdir="${java.dir}/antlibs/script" debug="${debug}">
      <classpath refid="classpath.script"/>
    </javac>
    <jar basedir="${bin.dir}/antlibs/script" jarfile="${distlib.dir}/antlibs/script.tsk">
      <metainf dir="${java.dir}/antlibs/script" 
                includes="antlib.xml"/>
    </jar>
  </target>
</project>
