<?xml version='1.0' ?>
<project name="antlib" default="all">
  <property name='orig' location='../../..' />
  <property name='orig-build' location='${orig}/build' />
  <property name='orig-classes' location='${orig-build}/classes' />
  <property name='build' location='build' />
  <property name='dist' location='dist' />
  <property name='classes' location='${build}/classes' />
  <property name='testcases' location='src/testcases' />

  <property name="debug" value="true" />
  <property name="deprecation" value="false" />
  <property name="optimize" value="true" />


  <target name='init'>
    <ant target='build' dir='${orig}' inheritAll='false' />
    <mkdir dir='${classes}' />
    <copy toDir='${classes}' preservelastmodified='true' >
      <fileset dir='${orig-classes}'>
        <include name='**' />
        <exclude name='org/apache/tools/ant/Project.class' />
        <exclude name='org/apache/tools/ant/ProjectHelper.class' />
        <exclude name='org/apache/tools/ant/IntrospectionHelper.class' />
        <exclude name='org/apache/tools/ant/TaskAdapter.class' />
        <exclude name='org/apache/tools/ant/taskdefs/Ant.class' />
      </fileset>
    </copy>
  </target>

  <target name='all' depends='init, build' />

  <target name='fullbuild' depends='init, compile'>
    <ant target='internal_dist' dir='${orig}'>
      <property name="build.dir" value="${build}"/>
      <property name="dist.dir" value="${dist}"/>
    </ant>
  </target>

  <target name='build' depends='init, compile'>
    <ant target='dist-lite' dir='${orig}'>
      <property name="build.dir" value="${build}"/>
      <property name="dist.dir" value="${dist}"/>
    </ant>
    <!--
        Rejar things to use lib descriptors
        It needs to work with the original ANT processor
    -->
    <path id="newtasks">
        <pathelement location="${classes}" />
    </path>
    <taskdef name="antjar" classname="org.apache.tools.ant.taskdefs.Antjar"
            classpathref="newtasks" />
    <taskdef name="antlib" classname="org.apache.tools.ant.taskdefs.Antlib"
            classpathref="newtasks" />
    <mkdir dir='${dist}/autolib' />
    <antjar antxml="src/main/org/apache/tools/ant/opt-antlib.xml"
            destfile="${dist}/autolib/optional.jar" >
        <zipfileset src="${dist}/lib/optional.jar" >
            <include name="**/*" />
        </zipfileset>
    </antjar>
    <antjar antxml="src/main/org/apache/tools/ant/antlib.xml"
            destfile="${dist}/lib/newant.jar" >
        <zipfileset src="${dist}/lib/ant.jar" >
            <include name="**/*" />
        </zipfileset>
    </antjar>
    <delete file="${dist}/lib/optional.jar" />
    <move file="${dist}/lib/newant.jar" tofile="${dist}/lib/ant.jar"/>
  </target>

  <target name='compile'>
    <javac srcdir='src/main' destdir='${classes}'
           debug="${debug}"
           deprecation="${deprecation}"
           optimize="${optimize}">
      <include name='**/*.java'/>
    </javac>
    <copy toDir='${classes}' preservelastmodified='true' >
      <fileset dir='src/main'>
        <include name='**/*.xml' />
      </fileset>
    </copy>
  </target>

  <target name='clean'>
    <delete dir='${build}' />
  </target>

  <target name='test'>
    <ant dir='${testcases}' inheritAll='false'/>
    <ant dir='${testcases}'
         antfile='${testcases}/case.xml' inheritAll='false'/>
  </target>

  <target name='cleanall' depends='clean'>
    <delete dir='${dist}' />
  </target>
</project>