<?xml version="1.0"?>

<project default="jar" basedir="..">

  <property name="build.dir"      location="build"/>
  <property name="test.dir"      location="test"/>
  <property name="doc.dir"        location="doc/api"/>
  <property name="dist.dir"       location="dist"/>
  <property name="api.dir"        location="api/src/java"/>
  <property name="impl.dir"       location="impl/src/java"/>

  <target name="prepare">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${test.dir}"/>
    <mkdir dir="${doc.dir}"/>
    <mkdir dir="${dist.dir}"/>
  </target>

  <target name="clean">
    <delete failonerror="false" dir="${build.dir}"/>
    <delete failonerror="false" dir="${test.dir}"/>
    <delete failonerror="false" dir="${doc.dir}"/>
    <delete failonerror="false" dir="${dist.dir}"/>
  </target>

  <target name="compile" depends="prepare">
    <javac srcdir="${api.dir}" 
	   destdir="${build.dir}" debug="true" nowarn="true" source="1.3" target="1.3"/>
    <javac srcdir="${impl.dir}" 
	   destdir="${build.dir}" debug="true" nowarn="true" source="1.3" target="1.3"/>
  </target>

  <target name="compile-tests" depends="compile">
    <javac srcdir="api/src/test" 
	   destdir="${test.dir}" debug="true" nowarn="true" classpath="${build.dir}"/>
    <javac srcdir="impl/src/test" 
	   destdir="${test.dir}" debug="true" nowarn="true" classpath="${build.dir}"/>
  </target>

  <target name="jar" depends="compile-tests">
    <jar destfile="${dist.dir}/avalon-framework.jar">
      <fileset dir="${build.dir}"/>
    </jar>   
  </target>

  <target name="doc">
    <javadoc destdir="${doc.dir}" source="1.3">
      <fileset dir="${api.dir}"/>
      <fileset dir="${impl.dir}"/>
    </javadoc>
  </target>

  <target name="test-all" depends="compile-tests">
      <junit printsummary="yes">
      <batchtest>
        <fileset dir="api/src/test">
          <include name="**/*TestCase.java"/>
        </fileset>
        <fileset dir="impl/src/test">
          <include name="**/*TestCase.java"/>
        </fileset>
      </batchtest>      
     <classpath>
        <pathelement location="${dist.dir}/avalon-framework.jar"/>
        <pathelement location="${test.dir}"/>
      </classpath>
    </junit>
  </target>

</project>
