<project name="OpenEJB-OpenEJB" default="jar" basedir="../">
  <!-- 
  		Contributions by:
  			Daniel S. Haischt <sirabyss@gmx.net>
  	-->

  <property name="build.openejb.src" value="${build.src}/openejb"/>
  <property name="build.openejb.dest" value="${build.dest}/openejb"/>
  <property name="dest.openejb.javadoc.dir" value="${dest.javadoc.dir}/openejb"/>
  
  <!-- Build classpath -->
  <path id="project.classpath">
    <pathelement location="${jrefactory.jar}"/>
    <pathelement location="${castor.home}/${castor.jar}"/>
    <pathelement location="${castor.home}/${castor.xml.jar}"/>
    <pathelement location="${ejb11.jar}"/>
    <pathelement location="${ejb20.jar}"/>
    <pathelement location="${jaas.home}/${jaas.jar}"/>
    <pathelement location="${jca.jar}"/>
    <pathelement location="${jdbcext.jar}"/>
    <pathelement location="${jdk12proxy.jar}"/>
    <pathelement location="${jedi.home}/lib/${jedi.jar}"/>
    <pathelement location="${jedi.home}/lib/${jediplugin.jar}"/>
    <pathelement location="${jms.jar}"/>
    <pathelement location="${jndi.jar}"/>
    <pathelement location="${jta.jar}"/>
    <pathelement location="${log4j.jar}"/>
    <pathelement location="${minerva.jar}"/>
    <pathelement location="${openorb.home}/${openorb.jar}"/>
    <pathelement location="${openorb.home}/${openorb.rmi.jar}"/>
    <pathelement location="${openorb.home}/${openorb.tools.jar}"/>
    <pathelement location="${jts.jar}"/>
    <pathelement location="${tyrex.home}/${tyrex.jar}"/>
    <pathelement location="${tyrex.home}/${tyrex.iiop.jar}"/>
    <pathelement location="${jaxp.home}/jaxp.jar"/>
    <pathelement location="${jaxp.home}/${jaxp.parser.jar}"/>
    <pathelement location="${jaxp.home}/${jaxp.xsltprocessor.jar}"/>
    <pathelement location="${jaxp.home}/${jaxp.xalan1compat.jar}"/>
    <pathelement location="${junit.jar}"/>
    <pathelement location="${jakarta.regexp.jar}"/>
    <pathelement location="${xslp.jar}"/>
    <pathelement location="${JDBC3Fake.jar}"/>
  </path>
  
  
  <!-- ================================================================== -->
  <!-- Prepares the build directory                                       -->
  <!-- ================================================================== -->

  <target name="prepare">
  
    <mkdir dir="${build.openejb.src}"/>
    <mkdir dir="${build.openejb.dest}"/>
    <mkdir dir="${build.openejb.dest}/openejb"/>
    <mkdir dir="${build.openejb.dest}/openejb/dtds"/>
    <mkdir dir="${dest.openejb.javadoc.dir}"/>
    
    <copy todir="${build.openejb.src}">
      <fileset dir="${src.java.dir}/main" 
               excludes="**/CVS/**,**/*.class"
      />
    </copy>
    
    <copy todir="${build.openejb.src}" >
      <fileset dir="${src.java.dir}/facilities" 
               includes="**/alt/**,**/resource/**,**/tyrex/**,**/sp/**" 
               excludes="**/CVS/**,**/modern/**,**/admin/**,**/minerva/**,**/*.class" />
    </copy>
    
    <copy todir="${build.openejb.dest}">
      <fileset dir="conf"
               includes="default*.*" 
               excludes="*service-jar.xml"
               />
    </copy>
    
    <copy file="conf/default.service-jar.xml"
      tofile="${build.openejb.dest}/org/openejb/service-jar.xml"/>
        
    <copy todir="${build.openejb.dest}/openejb">
      <fileset dir="bin" includes="*.txt" />
    </copy>
    
    <copy todir="${build.openejb.dest}/openejb/dtds">
      <fileset dir="src/schema" includes="*.dtd" />
    </copy>
    
    <echo file="${build.openejb.dest}/openejb-version.properties">copyright=Copyright ${year} (C) ${copyright}, All Rights Reserved.
url=${url}
version=${version}
date=${DSTAMP}
time=${TSTAMP}</echo>

  </target>
  
  <target name="copy.manifest">
  
    <copy todir="${build.openejb.dest}">
    
      <fileset dir="${src.java.dir}/etc" >
        <include name="**/LICENSE"/>
        <include name="**/MANIFEST.MF"/>
        <include name="**/README"/>
      </fileset>
    
    </copy>

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

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

	</copy>

    <replace file="${build.openejb.dest}/MANIFEST.MF" token="$$VERSION$$" value="${version}"/>
  
  </target>
  
  <target name="copy.i18n">
  
    <copy todir="${build.openejb.dest}">
    
      <fileset dir="${src.java.dir}/main" >
        <include name="**/resources/*.properties"/>
      </fileset>
    
      <fileset dir="${src.java.dir}/facilities" >
        <include name="**/rules/*.properties"/>
      </fileset>
    </copy>
  
  </target>
  
  <!-- ================================================================== -->
  <!-- Compiles the source directory                                      -->
  <!-- ================================================================== -->
  
  <target name="compile" description="--> compiles the java source files">
    <antcall target="compile.jdk.${ant.java.version}"/>
  </target>
  
  <target name="compile.jdk.1.1">
    <echo message="The OpenEJB Container System does not yet support JDK 1.1"/>          
  </target>
  
  <target name="compile.jdk.1.2" depends="prepare">
    <javac srcdir="${build.openejb.src}"
           destdir="${build.openejb.dest}"
           excludes="**/Jdk13*.java"
           classpathref="project.classpath"
           debug="${debug}"
           deprecation="${deprecation}"/>
          
  </target>
  
  <target name="compile.jdk.1.3" depends="prepare">
    <javac srcdir="${build.openejb.src}"
           destdir="${build.openejb.dest}"
           classpathref="project.classpath"
           debug="${debug}"
           deprecation="${deprecation}"/>
          
  </target>
  
  <target name="compile.jdk.1.4" depends="prepare">
    <javac srcdir="${build.openejb.src}"
           destdir="${build.openejb.dest}"
           classpathref="project.classpath"
           debug="${debug}"
           deprecation="${deprecation}"/>
          
  </target>
  
  <!-- ================================================================== -->
  <!-- Compiles the source directory and creates a .jar file              -->
  <!-- ================================================================== -->
  
  <target name="jar"
          depends="compile, copy.manifest, copy.i18n"
          description="--> generates all java archives (default)">
          
    <jar jarfile="dist/${project}-${version}.jar"
         basedir="${build.openejb.dest}"
         manifest="${build.openejb.dest}/MANIFEST.MF"/>
          
            
    <copy todir="${build.openejb.dest}">
      <fileset dir="src/schema"
               includes="openejb-*.dtd" />
    </copy>

          
    <!--    
    <jar jarfile="dist/${project}-plugin-${version}.jar"
         basedir="${build.openejb.dest}"
         includes="*.dtd,*.properties,default*.*"
         manifest="${build.openejb.dest}/MANIFEST.MF"/>
    -->
          
  </target>
  
  <!-- ================================================================== -->
  <!-- Creates the API documentation                                      -->
  <!-- ================================================================== -->
  
  <target name="javadocs"
          depends="compile"
          description="--> generates the API documentation">
          
    <javadoc packagenames="org.openejb.*,javax.ejb.*"
             sourcepath="${build.openejb.src}"
             destdir="${dest.openejb.javadoc.dir}"
             doctitle="${name} JavaDoc"
             windowtitle="${name} JavaDoc"
             bottom="${copyright}"
		     package="true"
             author="true"
             version="true"
             noindex="true"
             classpathref="project.classpath"/>
          
  </target>
  
</project>
