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

  <property name="build.openejb.server.src" value="${build.src}/server"/>
  <property name="build.openejb.server.dest" value="${build.dest}/server"/>
  <property name="dest.openejb.server.javadoc.dir" value="${dest.javadoc.dir}/server"/>
  
  <!-- Build classpath -->
  <path id="project.classpath">
    <pathelement location="${castor.home}/dist/${castor.jar}"/>
    <pathelement location="${ejb11.jar}"/>
    <pathelement location="${ejb20.jar}"/>
    <pathelement location="${jaas.home}/lib/${jaas.jar}"/>
    <pathelement location="${jca.jar}"/>
    <pathelement location="${jdbcext.jar}"/>
    <pathelement location="${jdk12proxy.jar}"/>
    <pathelement location="${jms.jar}"/>
    <pathelement location="${jndi.jar}"/>
    <pathelement location="${jta.jar}"/>
    <pathelement location="${log4j.jar}"/>
    <pathelement location="${jts.jar}"/>
    <pathelement location="${tyrex.home}/dist/${tyrex.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}"/>
  </path>
  
  <!-- ================================================================== -->
  <!-- Prepares the build directory                                       -->
  <!-- ================================================================== -->

  <target name="prepare">
  
    <mkdir dir="${build.openejb.server.src}"/>
    <mkdir dir="${build.openejb.server.dest}"/>
    <mkdir dir="${dest.openejb.server.javadoc.dir}"/>
    
    <mkdir dir="${build.openejb.server.dest}/openejb/server"/>
    
    <copy todir="${build.openejb.server.src}">
    
      <fileset dir="${src.java.dir}/server" >
        <include name="**/**"/>
        <exclude name="**/CVS/**"/>
        <exclude name="**/*.class"/>
      </fileset>
    
    </copy>
    
  </target>
  
  <target name="copy.manifest">
  
    <copy todir="${build.openejb.server.dest}">
    
      <fileset dir="${src.java.dir}/etc" >
        <include name="**/CHANGELOG"/>
        <include name="**/LICENSE"/>
        <include name="**/MANIFEST.MF"/>
        <include name="**/README"/>
      </fileset>
    
    </copy>
    
    <copy todir="${build.openejb.server.dest}">
    
      <fileset dir="${final.dir}/src/etc" >
        <include name="**/CHANGELOG"/>
      </fileset>
    
    </copy>
    
    <replace file="${build.openejb.server.dest}/MANIFEST.MF" token="$$VERSION$$" value="${version}"/>
  
  </target>
    
    <target name="copy.i18n">
    
      <copy todir="${build.openejb.server.dest}">
      
        <fileset dir="${src.java.dir}/server" >
          <include name="**/resources/*.properties"/>
        </fileset>
      
      </copy>
    
    </target>

  <!-- ================================================================== -->
  <!-- Compiles the source directory                                      -->
  <!-- ================================================================== -->
  
  <target name="compile"
          depends="prepare, compile.jdk12, compile.jdk13"
          description="--> compiles the java source files"/>
           
    <target name="compile.jdk12" unless="jdk13">
            
		<delete>
			<fileset dir="${build.openejb.server.src}" includes="**/Jdk13*.java"/>
		</delete>

		<javac srcdir="${build.openejb.server.src}"
			   destdir="${build.openejb.server.dest}"
			   debug="${debug}"
			   deprecation="${deprecation}">

		  <classpath>
			<path refid="project.classpath"/>
			<pathelement location="${build.dest}/openejb"/>
			<pathelement location="${build.dest}/loader"/>
		  </classpath>

		</javac>
            
    </target>
    
    <target name="compile.jdk13" if="jdk13">
            
		<javac srcdir="${build.openejb.server.src}"
			   destdir="${build.openejb.server.dest}"
			   debug="${debug}"
			   deprecation="${deprecation}">

		  <classpath>
			<path refid="project.classpath"/>
			<pathelement location="${build.dest}/openejb"/>
			<pathelement location="${build.dest}/loader"/>
		  </classpath>

		</javac>
            
    </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}_server-${version}.jar"
         basedir="${build.openejb.server.dest}"
         manifest="${build.openejb.server.dest}/MANIFEST.MF"/>
    
    <jar jarfile="dist/${project}_client-${version}.jar"
         basedir="${build.openejb.server.dest}"
         excludes="**/server/**"
         manifest="${build.openejb.server.dest}/MANIFEST.MF"/>
          
          
  </target>
  
  <!-- ================================================================== -->
  <!-- Creates the API documentation                                      -->
  <!-- ================================================================== -->
  
  <target name="javadocs"
          depends="compile"
          description="--> generates the API documentation">
          
    <javadoc packagenames="org.openejb.server.*,org.openejb.client.*"
             sourcepath="${build.openejb.server.src}"
             destdir="${dest.openejb.server.javadoc.dir}"
             doctitle="${name} OpenEJB Server 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>
