<!-- $Id: build.xml,v 12.2 2006/06/09 14:32:17 mark Exp $ -->
<project name="clover" default="test" basedir=".">

  <property name="db" location="../../.."/>
  <property name="src" location="${db}/java/src"/>
  <property name="test.src" location="${db}/test/scr024/src"/>
  <property name="examples.src" location="${db}/examples_java/src"/>
  <property name="testserialdir" value="testserial"/>
  <property name="clover.initstring" location="reports/clover.db"/>
  <property name="clover.excludes" value="**/test/** collections/** db/** com/sleepycat/db/**"/>
  <!--
  <property name="build.compiler"
            value="org.apache.tools.ant.taskdefs.CloverCompilerAdapter"/>
  -->

  <target name="all" depends="clean,test,report"/>

  <target name="clean">
    <delete dir="classes"/>
    <delete dir="tmp"/>
    <delete dir="reports"/>
  </target>

  <target name="init">
    <mkdir dir="classes"/>
    <mkdir dir="tmp"/>
    <mkdir dir="reports"/>
  </target>

  <path id="clover.classpath">
    <pathelement location="clover.jar"/>
    <pathelement location="velocity.jar"/>
  </path>

  <path id="classpath">
    <pathelement location="classes"/>
    <path refid="clover.classpath"/>
  </path>

  <target name="build" depends="init">
    <javac destdir="classes" debug="on" source="1.3">
      <src path="${src}"/>
      <src path="${test.src}"/>
      <src path="${examples.src}"/>
      <exclude name="com/sleepycat/**/release/**"/>
      <exclude name="com/sleepycat/xa/**"/>
    </javac>
    <property name="testserialpath"
              value="com/sleepycat/collections/test/serial/TestSerial"/>
    <copy file="${test.src}/${testserialpath}.java.original"
          tofile="${testserialdir}/${testserialpath}.java"/>
    <javac destdir="${testserialdir}" debug="on" source="1.3"
           includeAntRuntime="true" srcdir="${testserialdir}">
      <include name="${testserialpath}.java"/>
    </javac>
  </target>

  <target name="test" depends="build">

    <!-- Performs initialization needed before StoredClassCatalogTest is run in
         the <batchtest> below.
    -->
    <junit fork="yes" dir="." printsummary="on" haltonfailure="on"
           showoutput="on">
      <classpath path="${testserialdir}"/> <!-- Must be first -->
      <classpath refid="classpath"/>
      <formatter type="plain" usefile="false"/>
      <formatter type="xml"/>
      <test
      name="com.sleepycat.collections.test.serial.StoredClassCatalogTestInit"
            todir="reports"/>
    </junit>

    <junit fork="yes" dir="." printsummary="on" haltonfailure="on"
           showoutput="on">
      <formatter type="xml"/>
      <classpath refid="classpath"/>
      <sysproperty key="longtest" value="${longtest}"/>
      <batchtest todir="reports">
        <fileset dir="classes" includes="**/*Test.class"/>
      </batchtest>
      <!--
      -->
      <!--
      <test name="com.sleepycat.collections.KeyRangeTest" todir="reports"/>
      <test name="com.sleepycat.collections.test.TransactionTest" todir="reports"/>
      <test name="com.sleepycat.collections.test.CollectionTest" todir="reports"/>
      -->
    </junit>
  </target>

  <target name="examples" depends="build">
    <antcall target="one_shipment_example">
      <param name="param_name" value="basic"/>
    </antcall>
    <antcall target="one_shipment_example">
      <param name="param_name" value="index"/>
    </antcall>
    <antcall target="one_shipment_example">
      <param name="param_name" value="entity"/>
    </antcall>
    <antcall target="one_shipment_example">
      <param name="param_name" value="tuple"/>
    </antcall>
    <antcall target="one_shipment_example">
      <param name="param_name" value="sentity"/>
    </antcall>
    <antcall target="one_shipment_example">
      <param name="param_name" value="marshal"/>
    </antcall>
    <antcall target="one_shipment_example">
      <param name="param_name" value="factory"/>
    </antcall>
    <echo message=""/>
    <echo message="=== HelloDatabaseWorld ==="/>
    <java dir="." fork="yes" classpathref="classpath"
         classname="collections.hello.HelloDatabaseWorld"/>
  </target>

  <target name="one_shipment_example">
    <echo message="=== ${param_name} ==="/>
    <delete dir="tmp"/>
    <mkdir dir="tmp"/>
    <java dir="." fork="yes" classpathref="classpath"
     classname="collections.ship.${param_name}.Sample"/>
  </target>

    <!-- Using fork="yes" does not work for AccessExample, apparently because
         it is interactive and the input stream of the forked process isn't
         functional; therefore this sample writes to the base directory.
    -->
  <target name="access_example" depends="build">
    <echo message="=== AccessExample ==="/>
    <java classpathref="classpath"
          classname="collections.access.AccessExample">
    </java>
  </target>

  <target name="report">
    <java classname="com.cortexeb.tools.clover.reporters.html.HtmlReporter"
          fork="true">
       <arg line="--outputdir reports --showSrc --initstring ${clover.initstring} --title 'Berkeley DB Java BDB API'"/>
       <classpath refid="clover.classpath"/>
    </java>
  </target>

</project>

