<project name="OpenEJB-Testsuite" default="jar" basedir="../">
  
  <property name="build.testsuite.src" value="${build.src}/tests-unit"/>
  <property name="build.testsuite.dest" value="${build.dest}/tests-unit"/>
  <property name="src.test.dir" value="${src.dir}/tests-unit"/>
  <property name="dest.testsuite.javadoc.dir" value="${dest.javadoc.dir}/testsuite"/>
  
  <!-- Build classpath -->
  <path id="project.classpath">
    <pathelement location="${ejb11.jar}"/>
    <pathelement location="${ejb20.jar}"/>
    <pathelement location="${jms.jar}"/>
    <pathelement location="${jndi.jar}"/>
    <pathelement location="${jta.jar}"/>
    <pathelement location="${junit.jar}"/>
  </path>
  
  
  <!-- ================================================================== -->
  <!-- Prepares the build directory                                       -->
  <!-- ================================================================== -->

  <target name="prepare">
  
    <mkdir dir="${build.testsuite.src}"/>
    <mkdir dir="${build.testsuite.dest}"/>
    <mkdir dir="${dest.testsuite.javadoc.dir}"/>
    
    <copy todir="${build.testsuite.src}">
    
      <fileset dir="${src.test.dir}" >
        <include name="**/validator/**"/>
        <exclude name="**/CVS/**"/>
        <exclude name="**/javax/**"/>
        <exclude name="**/*.class"/>
      </fileset>
    
    </copy>
        
  </target>
  
  <target name="copy.manifest">
  
    <copy todir="${build.testsuite.dest}">
    
      <fileset dir="${src.java.dir}/etc" >
        <include name="**/LICENSE"/>
        <include name="**/MANIFEST.MF"/>
        <include name="**/README"/>
      </fileset>

      <fileset dir="${src.test.dir}" >
        <include name="**/ejb-jar.xml"/>
      </fileset>

    </copy>

	<copy todir="${build.testsuite.dest}">

	  <fileset dir="${final.dir}/src/etc" >
		<include name="**/CHANGELOG"/>
	  </fileset>

	</copy>



    <copy file="${src.test.dir}/org/openejb/test/validator/ejb-jar.xml"
         tofile="${build.testsuite.dest}/META-INF/ejb-jar.xml" />
    
    <replace file="${build.testsuite.dest}/MANIFEST.MF" token="$$VERSION$$" value="${version}"/>
  
  </target>
  
  <!-- ================================================================== -->
  <!-- Compiles the source directory                                      -->
  <!-- ================================================================== -->
  
  <target name="compile"
          depends="prepare"
          description="--> compiles the java source files">
          
    <javac srcdir="${build.testsuite.src}"
           destdir="${build.testsuite.dest}"
           debug="${debug}"
           deprecation="${deprecation}">
           
      <classpath>
        <path refid="project.classpath"/>
      </classpath>
           
    </javac>
          
  </target>
  
  <!-- ================================================================== -->
  <!-- Compiles the source directory and creates a .jar file              -->
  <!-- ================================================================== -->
  
  <target name="jar"
          depends="compile, copy.manifest"
          description="--> generates all java archives (default)">
          
    <jar jarfile="beans/${project}_invalid_ejbs-${version}.jar"
         basedir="${build.testsuite.dest}"
         includes="org/openejb/test/validator/**,
                   META-INF/*.xml"
         manifest="${build.testsuite.dest}/MANIFEST.MF"/>

  </target>
  
  <!-- ================================================================== -->
  <!-- Creates the API documentation                                      -->
  <!-- ================================================================== -->
  
  <target name="javadocs"
          depends="compile"
          description="--> generates the API documentation">
          
    <javadoc packagenames="org.openejb.*"
             sourcepath="${build.testsuite.src}"
             destdir="${dest.testsuite.javadoc.dir}"
             doctitle="${name} Testsuite JavaDoc"
             windowtitle="${name} JavaDoc"
             bottom="${copyright}"
		     package="true"
             author="true"
             version="true"
             noindex="true">
             
      <classpath>
        <path refid="project.classpath"/>
        <pathelement location="${build.dest}/openejb"/>
      </classpath>
             
    </javadoc>
          
  </target>
  
</project>
