<?xml version="1.0"?>

<!-- ============================================ -->
<!-- Ant Build File for Berkeley DB Java Database -->
<!-- ============================================ -->

<project name="JE" default="jar" basedir=".">
<description>Compile and test JE</description>

    <fail message="Ant 1.7.0 or greater is required">
      <condition><not><antversion atleast="1.7.0"/></not></condition>
    </fail>

    <!-- Modify build.properties to point to the proper j2ee paths for
         JCA and JMX support  -->
    <property file="build.properties"/>

    <property name="srcdir" value="${basedir}/src"/>
    <property name="builddir" value="${basedir}/build"/>
    <property name="destdir" value="${builddir}/classes"/>
    <condition property="specificjar" value="${testjar}">
      <isset property="testjar"/>
    </condition>
    <condition property="specificjar" value="${destdir}">
      <not>
        <isset property="testjar"/>
      </not>
    </condition>
    <property name="libdir" value="${builddir}/lib"/>
    <property name="extdir" value="${basedir}/ext"/>

    <property name="dist.srcdir" value="${basedir}/dist"/>
    <property name="dist.destdir" value="${builddir}/dist"/>

    <property name="unittest.srcdir" value="${basedir}/test"/>
    <property name="unittest.dir" value="${builddir}/test"/>
    <property name="unittest.destdir" value="${unittest.dir}/classes"/>
    <property name="unittest.datadir" value="${unittest.dir}/data"/>
    <property name="unittest.extraenvdir" value="${unittest.destdir}/propTest"/>
    <property name="unittest.extraenvdir2" value="${unittest.destdir}/propTest2"/>
    <property name="unittest.reportsdir" value="${unittest.dir}/reports"/>
    <property name="unittest.testserialdir" value="${unittest.dir}/testserial"/>
    <property name="unittest.testevolvedir" value="${unittest.dir}/testevolve"/>

    <property name="doc.dir" value="${basedir}/docs"/>
    <property name="doc.javadir" value="${doc.dir}/java"/>
    <property name="docsrc.dir" value="${basedir}/docs_src"/>
    <property name="doclet.classes.dir"  
              value="${doc.dir}/doclet/Classes"/>
    <property name="doclet.src.dir" value="${doc.dir}/doclet"/>
    <property name="doclet.jar" value="${doc.dir}/HidingDoclet.jar"/>

    <property name="jarfile" value="${libdir}/je.jar"/>
    <property name="jcararfile" value="${libdir}/jejca.rar"/>
    <property name="srczipfile" value="${basedir}/src.zip"/>
    <property name="buildzipfile" value="${basedir}/build.zip"/>
    <property name="zipfile" value="${basedir}/je.zip"/>
    <property name="plugin.id" value="com.sleepycat.je"/>

    <property name="clover.tmpdir" value="${builddir}/tmp"/>
    <property name="clover.initstring"
              location="${clover.tmpdir}/jecoverage.db"/>
      <property name="clover.libdir" value="/clover/lib"/>
    <property name="clover.excludes" value="**/rpcserver/** **/je/examples/** **/je/junit/** **/*Test.java **/*TestBase.java **/compat/** **/je/util/**"/>

    <property name="example.srcdir" value="${basedir}/examples"/>
    <property name="example.destdir" value="${destdir}"/>

    <property name="packages" value="com.sleepycat.*"/>
    <property file="${user.home}/ant.properties"/>
    <property name="build.propertyfile"
              value="${dist.destdir}/build.properties"/>
    <property name="installdestdir" value="/usr/local"/>

    <!--
    Can be used to specify a different JVM for <java> tasks, for example:
      ant "-Djvm=/usr/local/jdk1.6.0_01/bin/java" ...
    -->
    <property name="jvm" value="java"/>

    <!--
    Can be used to override JVM args for <java> tasks, for example:
      ant "-Djvmargs=-Xmx32M -client" ...
    -->
    <property name="jvmargs" value=""/>

    <!--
    For unit testing using different default isolation levels.  May be:
     empty string (repeatableRead)
     readCommitted (degree 2)
     serializable (degree 3)
    -->
    <property name="isolationLevel" value=""/>

    <!-- For long and short version of unit tests. May be:
               empty string (false);
	       true
	       false
    -->
    <property name="longtest" value="false"/>

    <path id="empty.classpath"/>

    <path id="class.path">
      <pathelement location="${specificjar}"/>
      <pathelement location="."/>
    </path>

    <path id="unittest.classpath">
      <pathelement location="${specificjar}"/>
      <pathelement location="."/>
      <pathelement location="${unittest.destdir}"/>
    </path>

    <path id="clover.classpath">
      <pathelement path="${clover.libdir}/clover.jar"/>
      <pathelement path="${clover.libdir}/velocity.jar"/>
    </path>

    <path id="unittest-j2ee.classpath">
      <pathelement location="${destdir}"/>
      <pathelement location="."/>
      <pathelement location="${unittest.destdir}"/>
      <pathelement location="${examples.destdir}"/>
      <pathelement path="${j2ee.jarfile}"/>
    </path>

    <path id="jca.classpath">
      <pathelement location="${destdir}"/>
      <pathelement location="."/>
      <pathelement path="${j2ee.jarfile}"/>
      <pathelement path="${example.resources}"/>
    </path>

    <path id="j2ee.classpath">
      <pathelement location="${destdir}"/>
      <pathelement location="."/>
      <pathelement path="${j2ee.jarfile}"/>
    </path>

    <fileset id="jarclasses" dir="${destdir}"
             includes="com/sleepycat/asm/**/*.class,
                       com/sleepycat/bind/**/*.class,
                       com/sleepycat/collections/**/*.class,
                       com/sleepycat/compat/**/*.class,
                       com/sleepycat/je/**/*.class,
                       com/sleepycat/persist/**/*.class,
                       com/sleepycat/util/**/*.class"
             excludes="com/sleepycat/je/rep/**/*.class"/>

    <target name="buildDbg">
    <description>debug the build file itself</description>
      <property name="classpath.string" refid="class.path"/>
      <property name="unittestclasspath.string" refid="unittest.classpath"/>
      <echoproperties/>
    </target>

    <!-- ============================================================ -->
    <!-- Global Targets                                               -->
    <!-- ============================================================ -->
    <target name="init">
        <mkdir dir="${builddir}"/>
        <mkdir dir="${destdir}"/>
        <mkdir dir="${libdir}"/>
        <mkdir dir="${dist.destdir}"/>
        <mkdir dir="${doc.dir}"/>
        <mkdir dir="${doc.javadir}"/>
        <mkdir dir="${clover.tmpdir}"/>
        <mkdir dir="${unittest.dir}"/>
        <mkdir dir="${unittest.destdir}"/>
        <mkdir dir="${unittest.extraenvdir}"/>
        <mkdir dir="${unittest.extraenvdir2}"/>
        <mkdir dir="${unittest.testserialdir}"/>
        <mkdir dir="${unittest.testevolvedir}"/>
        <tstamp/>
	<antcall target="do-internal">
	   <param name="target" value="init"/>
        </antcall>
    </target>

    <target name="compile"
            depends="compile-src,
	             compile-examples,
		     compile-unittest">
	<antcall target="do-internal">
	   <param name="target" value="compile"/>
        </antcall>
    </target>

    <target name="compile-j2ee"
            depends="check-j2ee-present,
	             compile-jmx,
	             compile-jca"/>
       
    <target name="check-j2ee-present">
        <available classname="javax.resource.ResourceException"
	           property="j2eelib.present">
	  <classpath refid="j2ee.classpath"/>
	</available>

	<fail message="You need to set the 'j2ee.jarfile' property in
	the build.properties file"
	      unless="j2eelib.present"/>

    </target>

    <!-- ====== Internal (non-public) targets delegated to internal.xml =======

    For each top level target in internal.xml, a target here is used to compile
    all JE and internal sources and then invoke the target via internal.xml.
    Any other parameters for each target are passed using properties (-D
    propName=propValue).
    ======================================================================= -->
    <target name="do-internal">
       <ant antfile="ant/internal.xml" target="${target}"
            inheritAll="true" inheritrefs="true"/>
    </target>
    
    <!-- ============================================================ -->
    <!-- Clean                                                        -->
    <!-- ============================================================ -->
    <target name="clean" depends="clean-src,
                                  clean-unittest,
                                  clean-clover,
				  clean-jar,
                                  clean-package">
	<antcall target="do-internal">
	   <param name="target" value="clean"/>
        </antcall>
    </target>

    <!-- ============================================================ -->
    <!-- Compiles                                                     -->
    <!-- ============================================================ -->
    <target name="clean-src" depends="init">
        <delete>
            <fileset dir="${destdir}"
             includes="**/*.class,**/package.html,**/*.xml"/>
        </delete>
        <delete dir="${dist.destdir}"/>
    </target>

    <target name="compile-src" depends="init">
        <ant antfile="ant/compile.xml" dir="." inheritall="false">
            <reference refid="class.path" torefid="compile.classpath"/>
        </ant>
        <!-- Enhance the built-in persistent proxy classes. -->
        <taskdef name="enhancer"
                 classname="com.sleepycat.persist.model.ClassEnhancerTask">
          <classpath refid="class.path"/>
        </taskdef>
        <enhancer verbose="off">
          <fileset dir="${destdir}"
                   includes="com/sleepycat/persist/impl/*Proxy.class"/>
        </enhancer>
    </target>

    <target name="compile-examples" depends="compile-src">
        <ant antfile="ant/compile.xml" dir="." inheritall="false">
            <property name="srcdir" value="${example.srcdir}"/>
            <property name="include" value="**/*.java"/>
            <property name="exclude1" value="jmx/**/*.java"/>
            <property name="exclude2" value="jca/**/*.java"/>
            <reference refid="class.path" torefid="compile.classpath"/>
        </ant>
    </target>

    <target name="compile-jmx" depends="check-j2ee-present,compile-src, init">
        <ant antfile="ant/compile.xml" dir="." inheritall="false">
            <reference refid="j2ee.classpath" torefid="compile.classpath"/>
            <property name="include" value="com/sleepycat/je/jmx/**/*.java"/>
            <property name="exclude2" value=""/>
        </ant>
    </target>

    <target name="compile-jmxexamples" depends="compile-jmx">
        <ant antfile="ant/compile.xml" dir="." inheritall="false">
            <reference refid="j2ee.classpath" torefid="compile.classpath"/>
            <property name="srcdir" value="${example.srcdir}"/>
            <property name="include" value="jmx/**/*.java"/>
            <property name="exclude2" value=""/>
        </ant>
    </target>

    <target name="compile-jca" depends="check-j2ee-present,compile-src">
        <ant antfile="ant/compile.xml" dir="." inheritall="false">
            <reference refid="j2ee.classpath" torefid="compile.classpath"/>
            <property name="include" value="com/sleepycat/je/jca/**/*.java"/>
            <property name="exclude1" value=""/>
        </ant>
    </target>

    <target name="compile-jcaexamples" depends="compile-jca">
        <ant antfile="ant/compile.xml" dir="." inheritall="false">
            <reference refid="j2ee.classpath" torefid="compile.classpath"/>
            <property name="srcdir" value="${example.srcdir}"/>
            <property name="include" value="jca/**/*.java"/>
            <property name="exclude1" value=""/>
        </ant>
    </target>

    <!-- for jar packaging -->
    <target name="compile-dist" depends="init">
        <javac srcdir="${dist.srcdir}"
               destdir="${dist.destdir}" 
               source="1.5">
            <classpath refid="class.path"/>
        </javac>
    </target>


    <!-- ============================================================ -->
    <!-- Jars                                                         -->
    <!-- ============================================================ -->
    <target name="clean-jar">
        <delete dir="${libdir}"/>
    </target>

    <!-- JE jar -->
    <target name="jar" depends="compile, clean-package">
        <jar jarfile="${jarfile}">
	<fileset refid="jarclasses"/>
        <manifest>
            <attribute name="Main-Class"
                       value="com.sleepycat.je.utilint.JarMain"/>
            <attribute name="Premain-Class"
                       value="com.sleepycat.persist.model.ClassEnhancer"/>
        </manifest>
        </jar>
    </target>

    <!-- jca jar -->
    <target name="jcajar" depends="compile-jca">
        <jar jarfile="${libdir}/jejca.jar">
	<fileset dir="${destdir}"
	         includes="com/sleepycat/je/jca/ra/**"/>
       </jar>
    </target>

    <target name="clean-jca" depends="init">
         <delete>
              <fileset dir="${destdir}"
               includes="**/jca/**/*.class,package"/>
         </delete>
         <delete dir="${dist.destdir}/**/jca"/>
    </target>

    <target name="jca" depends="jcajar,jar">
       <jar destfile="${jcararfile}">
	  <metainf dir="${srcdir}/com/sleepycat/je/jca/ra" includes="ra.xml"/>
	  <fileset dir="${libdir}" includes="jejca.jar"/>
	  <fileset dir="${libdir}" includes="je.jar"/>
       </jar>
    </target>

    <!-- JCA examples jar -->
    <target name="jca-examples" depends="compile-jcaexamples,jca">

	<jar jarfile="${libdir}/jejca-example.jar">
	   <metainf dir="${example.srcdir}/jca/simple"
	            includes="ejb-jar.xml"/>
	   <metainf dir="${example.jca.srcdir}"
	             includes="${example.jca.descriptorname}"/>
	   <fileset dir="${destdir}"
	      includes="jca/simple/*"
	      excludes="jca/simple/ExClient.class"
	   />
	</jar>
    </target>

    <!-- jmx jar -->
    <target name="jmx" depends="compile-jmx,jar">
        <jar jarfile="${libdir}/jejmx.jar">
	<fileset dir="${destdir}"
	         includes="com/sleepycat/je/jmx/**"/>
        </jar>
    </target>

    <!-- jmx examples jar -->
    <target name="jmx-examples" depends="compile-jmxexamples,jmx">
        <jar jarfile="${libdir}/jejmx-example.jar">
	<fileset dir="${destdir}" includes="jmx/**"/>
        </jar>
    </target>

    <!-- create hidingdoclet jar. -->
    <target name="jar-hidingdoclet" depends="init, copy-doc-materials">
        <delete dir="${doclet.classes.dir}"/>
	<delete file="${doclet.jar}"/>

	<mkdir dir="${doclet.classes.dir}"/>
	<javac srcdir="${doclet.src.dir}" destdir="${doclet.classes.dir}" source="1.5">
            <include name="*.java"/>
        </javac>	    

	<jar jarfile="${doclet.jar}">
            <fileset dir="${doclet.classes.dir}" includes="*.class"/>
	</jar>
    </target>


    <!-- Eclipse "wrapper plug-in" jar -->
    <target name="je-version" depends="compile-src">
       <java fork="yes" 
             classname="com.sleepycat.je.util.DbDump"
             outputproperty="version.result"
             failonerror="true">
	  <arg value="-V"/>
          <classpath refid="class.path"/>
       </java>

    </target>

    <target name="eclipsejar" depends="je-version,compile,clean-package">
        <property name="eclipsejarfile"
                  value="${libdir}/${plugin.id}_${version.result}.jar"/>
        <jar jarfile="${eclipsejarfile}">
	<fileset refid="jarclasses"/>
        <manifest>
            <attribute name="Export-Package"
                       value="com.sleepycat.bind,com.sleepycat.bind.serial,com.sleepycat.bind.tuple,com.sleepycat.collections,com.sleepycat.je,com.sleepycat.je.util,com.sleepycat.persist,com.sleepycat.persist.evolve,com.sleepycat.persist.model,com.sleepycat.persist.raw,com.sleepycat.util"/>
            <attribute name="Bundle-Vendor"
                       value="Oracle"/>
            <attribute name="Bundle-Version"
                       value="${version.result}"/>
            <attribute name="Eclipse-BuddyPolicy"
                       value="registered"/>
            <attribute name="Bundle-Name"
                       value="Berkeley DB Java Edition"/>
            <attribute name="Bundle-ManifestVersion"
                       value="2"/>
            <attribute name="Bundle-SymbolicName"
                       value="${plugin.id}"/>
        </manifest>
        </jar>
    </target>

    <!-- ============================================================ -->
    <!-- Package .jar and other files into a .zip                     -->
    <!-- ============================================================ -->
    <target name="clean-package">
        <delete file="${zipfile}"/>
        <delete file="${buildzipfile}"/>
        <delete file="${srczipfile}"/>
        <mkdir dir="${libdir}"/>
    </target>

    <target name="package" depends="jar, javadoc">
        <description>
            The package target builds the distribution package.
        </description>

	<!-- copy the README in, adding the current release number and date-->
        <copy overwrite="true" file="${dist.srcdir}/README" todir="${basedir}">
	   <filterset>
	       <filter token="RELEASE_VERSION" value="${release.version}"/>
	       <filter token="DATE" value="${release.date}"/>
	   </filterset>	
        </copy>	   

        <copy overwrite="true" file="${dist.srcdir}/example.properties"
            todir="${basedir}"/>

        <zip basedir="${builddir}"
             destfile="build.zip"
             includes="bin/**,lib/**,dist/build.properties"/>
        <zip basedir="${basedir}"
             destfile="src.zip"
             excludes="test/rpcserver/**,test/experiments/**,test/examples/**,test/regress/*/**,test/**/MiniStress.java,test/**/AbortStress.java,dist/,**/jca/README.txt,examples/com/**,src/com/sleepycat/je/rep/**,examples/je/rep/**,test/com/sleepycat/je/rep/**,test/standalone/scalability/**"
             includes="src/**,examples/**,test/**,docs/**,ant/**,regress/,build.xml,build.properties,example.properties,README,LICENSE,FindBugsExclude.xml"/>
        <zip basedir="${basedir}"
             destfile="${zipfile}"
             excludes="**/">
             <zipfileset src="build.zip"
                         prefix="je/"/>
             <zipfileset src="src.zip"
                         prefix="je/"/>
        </zip>
    </target>


    <!-- ============================================================ -->
    <!-- Testing                                                      -->
    <!-- ============================================================ -->

    <!-- ============================================================ -->
    <!-- JUnit unit tests                                             -->
    <!-- ============================================================ -->

    <target name="init-unittest" depends="init">
        <delete dir="${unittest.datadir}"/>
        <delete dir="${unittest.reportsdir}"/>
        <mkdir dir="${unittest.datadir}"/>
        <mkdir dir="${unittest.reportsdir}"/>
    </target>

    <target name="clean-unittest" depends="init-unittest">
        <delete dir="${unittest.destdir}"/>
        <mkdir dir="${unittest.destdir}"/>
        <delete dir="${unittest.testserialdir}"/>
        <mkdir dir="${unittest.testserialdir}"/>
        <delete dir="${unittest.testevolvedir}"/>
        <mkdir dir="${unittest.testevolvedir}"/>
    </target>

    <target name="compile-unittest" depends="compile-src">
      <ant antfile="ant/compile.xml" dir="." inheritall="false">
        <property name="srcdir" value="${unittest.srcdir}"/>
        <property name="destdir" value="${unittest.destdir}"/>
        <reference refid="unittest.classpath" torefid="compile.classpath"/>
      </ant>

      <copy todir="${unittest.destdir}">
        <fileset dir="${unittest.srcdir}" 
	         excludes="**/*.java,experiments/**,examples/**"/>
      </copy>

      <!-- for testing je.properties -->
      <copy file="${unittest.destdir}/com/sleepycat/je/je.properties"
            todir="${unittest.extraenvdir}"/>
      <!-- for testing rep.properties -->
      <copy file="${unittest.destdir}/com/sleepycat/je/rep.properties"
            tofile="${unittest.extraenvdir2}/je.properties"/>

      <!-- Compile original version of TestSerial class separately. -->
      <property name="testserialpath"
                value="com/sleepycat/collections/test/serial/TestSerial"/>
      <copy file="${unittest.srcdir}/${testserialpath}.java.original"
            tofile="${unittest.testserialdir}/${testserialpath}.java"/>
      <ant antfile="ant/compile.xml" dir="." inheritall="false">
          <property name="srcdir" value="${unittest.testserialdir}"/>
          <property name="destdir" value="${unittest.testserialdir}"/>
          <reference refid="class.path" torefid="compile.classpath"/>
      </ant>

      <!-- Compile original version of EvolveClasses separately. -->
      <property name="testevolvepath"
                value="com/sleepycat/persist/test/EvolveClasses"/>
      <copy file="${unittest.srcdir}/${testevolvepath}.java.original"
            tofile="${unittest.testevolvedir}/${testevolvepath}.java"/>
      <copy file=
             "${unittest.srcdir}/com/sleepycat/persist/test/EvolveCase.java"
            tofile=
             "${unittest.testevolvedir}/com/sleepycat/persist/test/EvolveCase.java"/>
      <copy file=
             "${unittest.srcdir}/com/sleepycat/persist/test/PersistTestUtils.java"
            tofile=
             "${unittest.testevolvedir}/com/sleepycat/persist/test/PersistTestUtils.java"/>
      <ant antfile="ant/compile.xml" dir="." inheritall="false">
          <property name="srcdir" value="${unittest.testevolvedir}"/>
          <property name="destdir" value="${unittest.testevolvedir}"/>
          <reference refid="class.path" torefid="compile.classpath"/>
      </ant>
    </target>

    <target name="compile-unittest-j2ee"
            depends="compile, compile-j2ee, compile-jmxexamples">
        <ant antfile="ant/compile.xml" dir="." inheritall="false">
            <property name="srcdir" value="${unittest.srcdir}"/>
            <property name="destdir" value="${unittest.destdir}"/>
            <property name="include" value="com/sleepycat/je/jmx/**/*.java"/>
            <property name="exclude2" value=""/>
            <reference refid="unittest-j2ee.classpath"
	               torefid="compile.classpath"/>
        </ant>
    </target>


    <!-- Do one of the following:

         ant test -Dtestcase=com.sleepycat.je.db.DbTest   (run one test)
         ant test -Dsuite=db                           (run one package)
         ant test                       (run all tests except rep tests)
         ant test -Dtestcase=com.sleepycat.je.db.DbTest -Dtestjar=je.jar
                                      (run one test with a specific jar)
         ant test -Dsuite=db -Dtestjar=je.jar 
                                   (run one package with a specific jar)
         ant test -Dtestjar=je.jar   (run all tests with a specific jar) 
         ant reptest              (run all com.sleepycat.je.rep.* tests)
     -->

    <target name="test-j2ee"
            depends="compile-unittest-j2ee,test"/>

    <target name="reptest">
	 <antcall target="test">
             <param name="param-rep" value="true"/>
	 </antcall>
    </target>

    <path id="testserial-classpath">
      <pathelement location="${unittest.testserialdir}"/>
    </path>

    <path id="testevolve-classpath">
      <pathelement location="${unittest.testevolvedir}"/>
    </path>

    <target name="test"
            depends="compile-unittest, init-unittest, jar">

      <!-- Determine which tests to run. -->
      <condition property="alltests">
        <not>
          <or>
            <isset property="suite"/>
            <isset property="testcase"/>
            <isset property="param-rep"/>
          </or>
        </not>
      </condition>
      <condition property="testserial">
        <or>
          <isset property="alltests"/>
          <contains string="${suite}" substring="serial"/>
          <equals arg1="${testcase}" arg2=
           "com.sleepycat.collections.test.serial.StoredClassCatalogTest"/>
        </or>
      </condition>
      <condition property="testevolve">
        <or>
          <isset property="alltests"/>
          <contains string="${suite}" substring="persist"/>
          <equals arg1="${testcase}"
                  arg2="com.sleepycat.persist.test.EvolveTest"/>
        </or>
      </condition>
      <condition property="testpersist">
        <or>
          <isset property="alltests"/>
          <contains string="${suite}" substring="persist"/>
        </or>
      </condition>

      <!-- Performs initialization needed before StoredClassCatalogTest. -->
      <antcall target="do-junit">
        <param name="param-msg" value="Run testserial initialization"/>
        <param name="param-if" value="testserial"/>
        <param name="param-jvmarg" value=""/>
        <param name="param-classpath" value="testserial-classpath"/>
        <param name="param-testcase" value=
         "com.sleepycat.collections.test.serial.StoredClassCatalogTestInit"/>
      </antcall>

      <!-- Performs initialization needed before persist evolve tests. -->
      <antcall target="do-junit">
        <param name="param-msg" value="Run testevolve initialization"/>
        <param name="param-if" value="testevolve"/>
        <param name="param-jvmarg" value=""/>
        <param name="param-classpath" value="testevolve-classpath"/>
        <param name="param-testcase"
               value="com.sleepycat.persist.test.EvolveTestInit"/>
      </antcall>

      <!-- Run all unit tests except for replication.  -->
      <antcall target="do-junit">
        <param name="param-msg" value="Run all unit tests"/>
        <param name="param-if" value="alltests"/>
        <param name="param-jvmarg" value=""/>
        <param name="param-classpath" value="empty.classpath"/>
        <param name="param-includes" value="**/*Test.class"/>
	<param name="param-excludes" value="**/rep/**/*Test.class"/>
      </antcall>

      <!-- Run a test suite.  -->
      <antcall target="do-junit">
        <param name="param-msg" value="Run a test suite: ${suite}"/>
        <param name="param-if" value="suite"/>
        <param name="param-jvmarg" value=""/>
        <param name="param-classpath" value="empty.classpath"/>
        <param name="param-includes" value="**/${suite}/*Test.class"/>
      </antcall>

      <!-- Run a single test case.  -->
      <antcall target="do-junit">
        <param name="param-msg" value="Run a test case: ${testcase}"/>
        <param name="param-if" value="testcase"/>
        <param name="param-jvmarg" value=""/>
        <param name="param-classpath" value="empty.classpath"/>
        <param name="param-testcase" value="${testcase}"/>
      </antcall>

      <!-- Run the persist test variants. -->
      <antcall target="test-persist-enhance-javaagent"/>
      <antcall target="test-persist-enhance-task"/>
      <antcall target="test-persist-enhance-main"/>

      <!-- Run the replication tests. -->
      <antcall target="do-junit">
        <param name="param-msg" value="Run replication tests only"/>
        <param name="param-if" value="param-rep"/>
        <param name="param-jvmarg" value=""/>
        <param name="param-classpath" value="empty.classpath"/>
        <param name="param-includes" value="**/rep/**/*Test.class"/>
      </antcall>

      <!-- Generate test reports -->

      <junitreport todir="${unittest.datadir}">
        <fileset dir="${unittest.datadir}">
          <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames"
          todir="${unittest.reportsdir}"/>
      </junitreport>
    </target>

    <!-- Run the persist tests with -javaagent to enhance classes. -->
    <target name="test-persist-enhance-javaagent" if="testpersist">
      <antcall target="do-junit">
        <param name="param-msg" value="Run persist tests with -javaagent"/>
        <param name="param-if" value="testpersist"/>
        <param name="param-sysprop-key" value="expectEnhanced"/>
        <param name="param-sysprop-value" value="true"/>
        <param name="param-jvmarg"
               value="-javaagent:${jarfile}=enhance:-v,com.sleepycat.persist"/>
        <param name="param-classpath" value="empty.classpath"/>
        <param name="param-includes"
               value="com/sleepycat/persist/**/*Test.class"/>
      </antcall>
    </target>

    <!-- Enhance persist test classes and run the persist tests again,
         setting the expectEnhanced system property to cause the test to
         fail if classes are not enhanced.  -->
    <property name="enhance-task.tmpdir" value="${builddir}/enhance.task"/>
    <path id="enhanced-task.classpath">
      <pathelement location="${enhance-task.tmpdir}"/>
    </path>
    <target name="test-persist-enhance-task" if="testpersist">
      <delete dir="${enhance-task.tmpdir}"/>
      <mkdir dir="${enhance-task.tmpdir}"/>
      <copy todir="${enhance-task.tmpdir}">
        <fileset dir="${unittest.destdir}"
                 includes="com/sleepycat/persist/**/*.class"/>
      </copy>
      <enhancer verbose="on">
        <fileset dir="${enhance-task.tmpdir}"/>
      </enhancer>
      <antcall target="do-junit">
        <param name="param-msg"
               value="Run persist tests with ClassEnhancer ant task"/>
        <param name="param-if" value="testpersist"/>
        <param name="param-sysprop-key" value="expectEnhanced"/>
        <param name="param-sysprop-value" value="true"/>
        <param name="param-jvmarg" value=""/>
        <param name="param-classpath" value="enhanced-task.classpath"/>
        <param name="param-includes"
               value="com/sleepycat/persist/**/*Test.class"/>
      </antcall>
    </target>

    <!-- Same as above but use the ClassEnhancer main program. -->
    <property name="enhance-main.tmpdir" value="${builddir}/enhance.main"/>
    <path id="enhanced-main.classpath">
      <pathelement location="${enhance-main.tmpdir}"/>
    </path>
    <path id="enhanced-main.classpath">
      <pathelement location="${enhance-main.tmpdir}"/>
      <path refid="class.path"/>
      <path refid="clover.classpath"/>
    </path> 
    <target name="test-persist-enhance-main" if="testpersist">
      <delete dir="${enhance-main.tmpdir}"/>
      <mkdir dir="${enhance-main.tmpdir}"/>
      <copy todir="${enhance-main.tmpdir}">
        <fileset dir="${unittest.destdir}"
                 includes="com/sleepycat/persist/**/*.class"/>
      </copy>
      <java fork="yes" jvm="${jvm}"
            classname="com.sleepycat.persist.model.ClassEnhancer">
        <jvmarg line="${jvmargs}"/>
        <arg line="-v ${enhance-main.tmpdir}"/>
        <classpath refid="enhanced-main.classpath"/>
      </java>
      <antcall target="do-junit">
        <param name="param-msg"
               value="Run persist tests with ClassEnhancer main program"/>
        <param name="param-if" value="testpersist"/>
        <param name="param-sysprop-key" value="expectEnhanced"/>
        <param name="param-sysprop-value" value="true"/>
        <param name="param-jvmarg" value=""/>
        <param name="param-classpath" value="enhanced-main.classpath"/>
        <param name="param-includes"
               value="com/sleepycat/persist/**/*Test.class"/>
      </antcall>
    </target>

    <!-- Called via antcall above to run the junit task.
     Specify one of these params:
      param-includes: path of class files to run a batchtest
      param-testcase: class name that to run a single test
     Required params:
      param-msg: message printed to identify this test run
      param-if: variable name that must be set to run tests
      param-jvmarg: value of additional jvmarg, may be empty
      param-classpath: refid of classpath to insert, may be empty.classpath
     Optional params:
      param-sysprop-key: key of additional sysproperty
      param-sysprop-value: value of additional sysproperty
      -->
    <target name="do-junit" if="${param-if}">
      <echo message="${param-msg}"/>
      <junit printsummary="false"
             errorProperty="unittest.failed"
             failureProperty="unittest.failed"
	     haltOnFailure="false"
             showoutput="true"
             fork="yes">
        <jvmarg value="-ea"/>
	<!--
        <jvmarg value="-d64"/>
	-->
        <jvmarg value="-Xmx256M"/>
        <jvmarg line="${param-jvmarg}"/>
        <classpath refid="${param-classpath}"/>
        <classpath refid="unittest.classpath"/>
        <classpath refid="clover.classpath"/>
        <sysproperty key="testdestdir" value="${unittest.destdir}"/>
        <sysproperty key="testevolvedir" value="${unittest.testevolvedir}"/>
        <sysproperty key="txnnosync" value="true"/>
	<sysproperty key="isolationLevel" value="${isolationLevel}"/>
	<sysproperty key="setErrorListener" value="true"/>
        <sysproperty key="longtest" value="${longtest}"/>
        <sysproperty key="${param-sysprop-key}"
                     value="${param-sysprop-value}"/>
        <sysproperty key="java.util.logging.config.file"
            value="${logging.config.file}"/>
        <formatter type="plain" usefile="false"/>
        <formatter type="xml"/>
        <test todir="${unittest.datadir}"
              if="param-testcase"
              name="${param-testcase}"/>
        <batchtest todir="${unittest.datadir}"
                   if="param-includes">
          <fileset dir="${unittest.destdir}" 
	           includes="${param-includes}"
                   excludes="${param-excludes}"/>
        </batchtest>
      </junit>
      <fail message="UnitTests failed.Check log and/or reports.">
        <condition>
          <and>
            <istrue value="${unittest.failed}"/>
	    <isfalse value="${clover.ignorefailure}"/>
	  </and>
	</condition>
      </fail>
    </target>

    <!-- Runs XxxTestMain test programs and other misc non-JUnit test. -->
    <target name="misctest" depends="compile-unittest, init-unittest">

      <antcall target="do-testmain">
        <param name="cls" value="je.test.SecondarySplitTestMain"/>
      </antcall>

      <!-- Special case JUnit test that only failed when run separately. -->
      <junit printsummary="false"
             showoutput="on"
	     haltOnFailure="true"
             fork="yes">
        <jvmarg value="-ea"/>
        <jvmarg value="-Xmx256M"/>
        <classpath refid="unittest-j2ee.classpath"/>
        <classpath refid="clover.classpath"/>
        <sysproperty key="testdestdir" value="${unittest.destdir}"/>
        <test name="com.sleepycat.je.dbi.SR12641"/>
      </junit>

    </target>

    <target name="do-testmain">
      <echo message="Running: ${cls}"/>
      <java fork="yes" failonerror="true" jvm="${jvm}"
            classname="com.sleepycat.${cls}">
        <jvmarg value="-Xmx256M"/>
        <jvmarg line="${jvmargs}"/>
        <sysproperty key="testdestdir" value="${unittest.destdir}"/>
        <classpath refid="unittest-j2ee.classpath"/>
        <classpath refid="clover.classpath"/>
      </java>
    </target>

    <!-- logversiondata is run at the end of each major release.  After running
         add the je-x.y.z.* files that were generated to CVS.  Be sure to use
         -kb to add the .jdb file.  Then add a test_x_y_z() method to
         com/sleepycat/je/logversion/LogEntryVersionTest.java.
    -->
    <target name="logversiondata" depends="compile-unittest">
      <java fork="yes" jvm="${jvm}"
            classname="com.sleepycat.je.logversion.MakeLogEntryVersionData">
        <jvmarg line="${jvmargs}"/>
        <arg line="${unittest.destdir}"/>
        <classpath refid="unittest.classpath"/>
      </java>
      <copy todir="test/com/sleepycat/je/logversion">
        <fileset dir="${unittest.destdir}">
          <include name="je-*.jdb"/>
          <include name="je-*.txt"/>
        </fileset>
      </copy>
    </target>

    <!-- ============================================================ -->
    <!-- Test CLI utils -->
    <!-- ============================================================ -->

    <target name="testcli"
        depends="testcli-dbdump"/>

    <target name="testcli-dbdump" depends="compile-src,compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.SimpleExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="tmp insert 5"/>
        <classpath refid="class.path"/>
      </java>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="com.sleepycat.je.util.DbDump">
        <jvmarg line="${jvmargs}"/>
        <arg line="-f ./dump.out -h tmp -s simpleDb"/>
        <classpath refid="class.path"/>
      </java>
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="com.sleepycat.je.util.DbLoad">
        <jvmarg line="${jvmargs}"/>
        <arg line="-f ./dump.out -h tmp -s simpleDb"/>
        <classpath refid="class.path"/>
      </java>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="com.sleepycat.je.util.DbDump">
        <jvmarg line="${jvmargs}"/>
        <arg line="-h tmp -r"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <!-- ========= Standalone test targets delegated to internal.xml ==========

    Standalone tests are run by passing the testcase property as the name of
    the target in internal.xml.  Other parameters for each target are passed
    using the args property, for example:

      ant -Dtestcase=MemoryStress -Dargs=-dups standalone

    See the individual standalone targets in ant/internal.xml for details.
    ======================================================================= -->
    <target name="standalone" depends="jar">
	<antcall target="do-internal">
	   <param name="target" value="standalone"/>
        </antcall>
    </target>

    <!-- ============================================================ -->
    <!-- Internal Use Only: Test examples -->
    <!-- ============================================================ -->

    <!-- testex runs all examples, but does not include testex-access because
         it is interactive.  Does not test JCA examples.
    -->
    <target name="testex"
        depends="testex-simple, testex-binding, testex-secondary,
        testex-sequence, testex-tomany, testex-measureinsertsize,
        testex-persist-person, testex-persist-dpldump,
        testex-persist-customkeyorder, testex-persist-eventexample,
        testex-persist-eventexampledpl, testex-persist-sqlapp,
        testex-hello, testex-ship-basic, testex-ship-index, testex-ship-entity,
        testex-ship-tuple, testex-ship-sentity, testex-ship-marshal,
        testex-ship-factory"/>

    <target name="testex-simple" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.SimpleExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="tmp insert 5"/>
        <classpath refid="class.path"/>
      </java>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.SimpleExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="tmp retrieve 5"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-binding" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.BindingExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="tmp insert 5"/>
	<classpath refid="class.path"/>
      </java>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.BindingExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="tmp retrieve 5"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-secondary" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.SecondaryExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="tmp insert 5"/>
        <classpath refid="class.path"/>
      </java>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.SecondaryExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="tmp retrieve 5"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-sequence" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.SequenceExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="tmp"/>
        <classpath refid="class.path"/>
      </java>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.SequenceExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="tmp"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-tomany" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.ToManyExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="-h tmp"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-measureinsertsize" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="je.MeasureInsertSize">
        <jvmarg line="${jvmargs}"/>
        <arg line="-h tmp -records 100 -key 10 -data 100"/>
        <classpath refid="class.path"/>
      </java>
      <echo>MeasureInsertSize ran OK</echo>
    </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="testex-access" depends="compile-examples">
      <java fork="yes" jvm="${jvm}"
            classname="collections.access.AccessExample">
        <jvmarg line="${jvmargs}"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-persist-person" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="persist.PersonExample">
        <jvmarg value="-ea"/>
        <jvmarg line="${jvmargs}"/>
        <arg line="-h tmp"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <!--
    Before running this example, first run another DPL example that writes to
    the tmp directory, such as testex-persist-person.
    -->
    <target name="testex-persist-dpldump" depends="compile-examples">
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="persist.DplDump">
        <jvmarg line="${jvmargs}"/>
        <arg line="-h tmp"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-persist-customkeyorder" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="persist.CustomKeyOrderExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="-h tmp"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-persist-eventexample" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="persist.EventExample">
        <jvmarg line="${jvmargs}"/>
        <arg line="-h tmp"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-persist-eventexampledpl" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="persist.EventExampleDPL">
        <jvmarg line="${jvmargs}"/>
        <arg line="-h tmp"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-persist-sqlapp" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="persist.sqlapp.SQLApp">
        <jvmarg line="${jvmargs}"/>
        <arg line="-h tmp"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-hello" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="collections.hello.HelloDatabaseWorld">
        <jvmarg line="${jvmargs}"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-ship-basic" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="collections.ship.basic.Sample">
        <jvmarg line="${jvmargs}"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-ship-index" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="collections.ship.index.Sample">
        <jvmarg line="${jvmargs}"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-ship-entity" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="collections.ship.entity.Sample">
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-ship-tuple" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="collections.ship.tuple.Sample">
        <jvmarg line="${jvmargs}"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-ship-sentity" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="collections.ship.sentity.Sample">
        <jvmarg line="${jvmargs}"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-ship-marshal" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="collections.ship.marshal.Sample">
        <jvmarg line="${jvmargs}"/>
        <classpath refid="class.path"/>
      </java>
    </target>

    <target name="testex-ship-factory" depends="compile-examples">
      <delete dir="${builddir}/tmp"/>
      <mkdir dir="${builddir}/tmp"/>
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="collections.ship.factory.Sample">
        <jvmarg line="${jvmargs}"/>
        <classpath refid="class.path"/>
      </java>
    </target>
        
    <!-- testex-jejca runs all JCA examples.
    -->
    <target name="testex-jejca"
        depends="testex-jejcasimple"/>

    <target name="testex-jejcasimple" depends="compile-jcaexamples">
      <java fork="yes" dir="${builddir}" jvm="${jvm}"
            classname="jca.simple.SimpleClient">
        <jvmarg line="${jvmargs}"/>
        <classpath refid="jca.classpath"/>
	<arg value="${key}"/>
	<arg value="${data}"/>
      </java>
    </target>

    <!-- ============================================================ -->
    <!-- Internal Use Only: Javadocs for Entire Source Tree           -->
    <!-- ============================================================ -->
    <target name="javadoc-all" depends="init">
        <mkdir dir="${doc.dir}"/>
        <javadoc packagenames="${packages}"
                maxmemory="128M"
                sourcepath="${srcdir}"
                destdir="${doc.dir}"
                classpathref="class.path"
                version="true"
                nodeprecated="false"
		windowtitle="${name} Classes"
                doctitle="${name}"
                package="true"
                source="1.5"
                bottom="Copyright (c) 2004,2008 Oracle.  All rights reserved.">

          <link href="http://java.sun.com/j2se/1.5/docs/api"/>
        </javadoc>
    </target>

    <!-- ============================================================ -->
    <!-- Javadocs for the public api for distribution                 -->
    <!-- This is a complex process that incorporates M4 processing of -->
    <!-- documentation template files.                                -->
    <!-- ============================================================ -->

    <!-- Make sure we update the version in the build properties file -->
    <path id="dist.classpath">
        <path refid="class.path"/>
	<pathelement location="${dist.destdir}"/>
    </path>

    <target name="update-version" depends="compile-src, compile-dist">
       <!-- Create an up to date property file for the build -->
       <java fork="yes" jvm="${jvm}"
             classname="CreateRELEASEFile"
	     classpathref="dist.classpath">
          <jvmarg line="${jvmargs}"/>
	  <arg value="${build.propertyfile}"/>
       </java>

       <!-- read it in -->
       <property file="${build.propertyfile}"/>
    </target>

    <target name="clean-javadoc" depends="init">
        <delete dir="${doc.dir}"/>
    </target>

    <!-- create javadoc -->
    <target name="javadoc" depends="init, update-version, clean-javadoc">

        <!-- create fresh directories --> 
        <mkdir dir="${doc.dir}"/>
        <mkdir dir="${doc.javadir}"/>

        <!-- set the time -->
        <tstamp>
	   <format property="release.date" pattern="MMMMMMMM dd, yyyy"/>
	</tstamp>

	<!-- Copy the main page, images and release notes, to the
             docs directory, putting in the release version where
	     appropriate -->
        <copy overwrite="true" todir="${doc.dir}">
	   <filterset>
	       <filter token="RELEASE_VERSION" value="${release.version}"/>
	       <filter token="RELEASE_NUMERIC_VERSION"
	               value="${release.numeric.versionc.version}"/>
	       <filter token="DATE" value="${release.date}"/>
	   </filterset>
	   <fileset dir="${docsrc.dir}">
               <include name="*.html"/>
               <include name="*.css"/>
           </fileset>
        </copy>
        <copy todir="${doc.dir}/images">
	    <fileset dir="${docsrc.dir}/images"/>
	</copy>
        <copy todir="${doc.dir}/sleepycat">
	    <fileset dir="${docsrc.dir}/sleepycat"/>
	</copy>

	<!-- Copy everything for the Getting Started Guide and the
             Writing Transactional Applications Guide to the docs 
             directory -->
        <copy todir="${doc.dir}/GettingStartedGuide">
	    <fileset dir="${docsrc.dir}/GettingStartedGuide">
	    </fileset>
	</copy>

        <copy todir="${doc.dir}/TransactionGettingStarted">
	    <fileset dir="${docsrc.dir}/TransactionGettingStarted">
	    </fileset>
	</copy>

	<!-- Copy everything for the collections tutorial to the docs 
             directory -->
        <copy todir="${doc.dir}/collections">
	    <fileset dir="${docsrc.dir}/collections">
	    </fileset>
        </copy>
	
	<antcall target="javadoc-src"/>
    </target>

    <available file="${docsrc.dir}" type="dir" property="UserOrMember"/>

    <target name="copy-doc-materials" if="UserOrMember">
        <copy overwrite="true" todir="${doclet.src.dir}">
            <fileset dir="${docsrc.dir}/doclet"/>
	</copy>

	<copy overwrite="true" todir="${doc.dir}" file="${docsrc.dir}/style.css"/>
    </target>

    <target name="javadoc-src" depends="init, copy-doc-materials">
	<antcall target="jar-hidingdoclet"/>
	
	<delete dir="${doc.dir}/java"/>
	<mkdir dir="${doc.dir}/java"/>

        <!-- Run javadoc on public API -->
	<echo>Javadoc public api</echo>
        <javadoc  sourcepath="${srcdir}"
                destdir="${doc.javadir}"
		version="true"
                nodeprecated="false"
		protected="true"
                source="1.5"
		use="true"
		docletpath="docs/HidingDoclet.jar"
		stylesheetfile="${doc.dir}/style.css"
		windowtitle="Oracle - Berkeley DB Java Edition API">
	  <classpath refid="j2ee.classpath"/>
	  <classpath path="${ant.library.dir}/ant.jar"/>
	  <arg value="-author"/>
	  <doclet name="HidingDoclet"/>
          <group title="Berkeley DB Java Edition Packages">
              <package name="com.sleepycat.je*"/>
              <package name="com.sleepycat.je.util"/>
              <package name="com.sleepycat.je.jmx"/>
              <package name="com.sleepycat.je.jca.ra"/>
	  </group>
          <group title="Berkeley DB Direct Persistence Layer (DPL) Packages">
              <package name="com.sleepycat.persist"/>
              <package name="com.sleepycat.persist.model"/>
              <package name="com.sleepycat.persist.evolve"/>
              <package name="com.sleepycat.persist.raw"/>
	  </group>
          <group title="Berkeley DB Bind and Collections Packages">
              <package name="com.sleepycat.bind*"/>
              <package name="com.sleepycat.collections*"/>
              <package name="com.sleepycat.util*"/>
	  </group>
	  <header><![CDATA[<b>Berkeley DB Java Edition</b><br><font size=\"-1\"> version ${release.version}</font>]]>
	  </header>
	  <bottom><![CDATA[<font size=1>Copyright (c) 2004,2008 Oracle.  All rights reserved.</font>]]> </bottom> 
          <package name="com.sleepycat.je"/>
          <package name="com.sleepycat.je.jmx"/>
         <!-- We'd like to include the com.sleepycat.je.jca.ra package
              and use the @hidden tag, but the doclet seems to have some
              problems there. -->
          <fileset dir="${srcdir}">
	        <include name="com/sleepycat/je/jca/ra/JEConnection.java"/>
	        <include name="com/sleepycat/je/jca/ra/JEConnectionFactory.java"/>	        
	        <include name="com/sleepycat/je/jca/ra/JEException.java"/>
          </fileset>
          <package name="com.sleepycat.je.util"/>
          <package name="com.sleepycat.collections"/>
          <package name="com.sleepycat.bind.*"/>
          <package name="com.sleepycat.persist"/>
          <package name="com.sleepycat.persist.model"/>
          <package name="com.sleepycat.persist.evolve"/>
          <package name="com.sleepycat.persist.raw"/>
          <package name="com.sleepycat.util"/>
          <link href="http://java.sun.com/j2se/1.5/docs/api"/>
          <link href="http://java.sun.com/javase/6/docs/api"/>
        </javadoc>
    </target>

    <target name="install">
    <description>Install JE into destdir</description>
      <condition property="isWindows">
         <os family="windows"/>
      </condition>
      <property file="dist/build.properties"/>
      <echo message="Installing JE into ${installdestdir}"/>
      <fail message="Install manually on Windows" if="isWindows"/>
      <property name="installdir"
             value="${installdestdir}/JE.${release.major}.${release.minor}"/>
      <mkdir dir="${installdir}"/>
      <mkdir dir="${installdir}/docs"/>
      <mkdir dir="${installdir}/bin"/>
      <mkdir dir="${installdir}/lib"/>
      <copy todir="${installdir}/docs">
         <fileset dir="docs">
	   <include name="**/*"/>
	 </fileset>
      </copy>
      <copy todir="${installdir}/lib">
	 <fileset dir="lib"/>
      </copy>
      <copy todir="${installdir}/bin">
	 <fileset dir="bin"/>
      </copy>
    </target>

    <!-- ============================================================ -->
    <!-- Clover, code coverage. To run with clover                    -->
    <!--        set the clover.libdir property above.                 -->
    <!--        make sure the clover.jar and clover.license are in    -->
    <!--           the ant/lib directory                              -->
    <!--        change inheritall=true above for the compile-src      -->
    <!--           target above.                                      -->
    <!--           and inheritall=false in ant/internal.xml to        -->
    <!--               inheritall=true                                -->
    <!--                                                              -->
    <!--  To run single test and generate report,we should type       -->
    <!--           ant clover.singletestdone                          -->
    <!--  and default single test is for no parameters, if you want   -->
    <!--  to change to other test, you can change the second parameter-->
    <!--  of the depends attribute of "clover.singletestrun" target   -->
    <!--                                                              -->
    <!--  To run all the tests and generate  report,we should type    -->
    <!--           ant clover.alltestsdone                            -->
    <!-- ============================================================ -->
    <target name="init-clover">
      <delete dir="${clover.tmpdir}"/>
      <mkdir dir="${clover.tmpdir}"/>
    </target>

    <target name="clean-clover" depends="init-clover">
      <delete dir="${clover.tmpdir}"/>
      <mkdir dir="${clover.tmpdir}"/>
    </target>

    <target name="clover.setup">
      <antcall target="clean"/>
      <antcall target="compile"/>
      <antcall target="clean-src"/>
      <taskdef resource="clovertasks"/>
      <clover-setup initString="${clover.tmpdir}/jecoverage.db"/>
      <antcall target="compile-src"/>
    </target>

    <target name="clover.runtest">
      <taskdef resource="clovertasks"/>
      <clover-setup initString="${clover.tmpdir}/jecoverage.db"/>
      <antcall target="test"/>
    </target>

    <target name="clover.runtest.LruOnly">
      <echo file="${unittest.srcdir}/je.properties" 
            message="je.evictor.lruOnly=true"/>
      <antcall target="clover.runtest"/>
      <echo file="${unittest.srcdir}/je.properties" message=""/>
    </target>

    <target name="clover.runtest.SharedLatches">
      <echo file="${unittest.srcdir}/je.properties" 
            message="je.env.sharedLatches=true"/>
      <antcall target="clover.runtest"/>
      <echo file="${unittest.srcdir}/je.properties" message=""/>
    </target>

    <target name="clover.runtest.Isolation">
      <echo file="${unittest.srcdir}/je.properties" 
            message="je.txn.serializableIsolation=true"/>
      <antcall target="clover.runtest"/>
      <echo file="${unittest.srcdir}/je.properties" message=""/>
    </target>

    <target name="clover.runtest.DirectNIO">
      <echo file="${unittest.srcdir}/je.properties">
        je.log.useNIO=true
        je.log.directNIO=true
      </echo>
      <antcall target="clover.runtest"/>
      <echo file="${unittest.srcdir}/je.properties" message=""/>  
    </target>

    <target name="clover.runtest.ChunkNIO">
      <echo file="${unittest.srcdir}/je.properties">
        je.log.useNIO=true
        je.log.chunkedNIO=4096
      </echo>
      <antcall target="clover.runtest"/>
      <echo file="${unittest.srcdir}/je.properties" message=""/>
    </target>
	
    <target name="clover.alltestsrun" 
            depends="clover.setup, clover.runtest, 
            clover.runtest.DirectNIO, clover.runtest.SharedLatches, 
            clover.runtest.LruOnly, clover.runtest.Isolation,
            clover.runtest.ChunkNIO">
    </target>

    <target name="clover.swing" depends="clover.alltestsrun">
      <taskdef resource="clovertasks"/>
      <clover-view/>
    </target>

    <target name="clover.log" depends="clover.alltestsrun">
      <taskdef resource="clovertasks"/>
      <clover-log/>
    </target>

    <target name="clover.pdf" depends="clover.alltestsrun">
      <taskdef resource="clovertasks"/>
      <clover-report>
      	<current outfile="jecoverage.pdf">
      	  <format type="pdf"/>
        </current>
      </clover-report>
    </target>

    <target name="clover.alltestsdone" depends="clover.alltestsrun">
      <taskdef resource="clovertasks"/>
      <clover-setup initString="${clover.tmpdir}/jecoverage.db"/>
      <clover-report>
        <current outfile="clover_html">
          <format type="html"/>
        </current>
      </clover-report>
    </target>

    <target name="clover.singletestdone" depends="clover.setup,clover.runtest">
      <taskdef resource="clovertasks"/>
      <clover-setup initString="${clover.tmpdir}/jecoverage.db"/>
      <clover-report>
        <current outfile="clover_html">
          <format type="html"/>
        </current>
      </clover-report>
    </target>

</project>
