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

  <property name="build.openejb.src" value="${build.src}/loader"/>
  <property name="build.openejb.dest" value="${build.dest}/loader"/>
  <property name="dest.openejb.javadoc.dir" value="${dest.javadoc.dir}/loader"/>
  
  <!-- 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="${dest.openejb.javadoc.dir}"/>
    
    <copy todir="${build.openejb.src}">
      <fileset dir="${src.java.dir}/main" 
        includes="org/openejb/util/ClasspathUtils*,
                  org/openejb/util/FileUtils.java"
                 
        excludes="**/CVS/**,**/*.class" /> </copy>
    
    <mkdir dir="${build.openejb.dest}/images" />
    
    <copy todir="${build.openejb.dest}/images" >
      <fileset dir="${src.java.dir}/doc/images" 
               includes="JavaCup.gif,
                        TreeClosed.gif,
                        TreeOpen.gif,
                        dotTrans.gif,
                        ejb.gif,
                        line_light.gif,
                        line_sm.gif,
                        logo_ejb2.gif,
                        pepper.gif,
                        stripe105.gif,
                        stripes1.gif,
                        top_2.gif,
                        top_3.gif"/>
    </copy>

    <copy todir="${build.openejb.dest}" >
      <fileset dir="${src.java.dir}/doc/tomcat" 
               includes="*.html"/>
    </copy>
    
    <copy todir="${build.openejb.dest}" >
      <fileset dir="${src.java.dir}/doc/style" 
               includes="default.css"/>
    </copy>
    
    <copy todir="${build.openejb.src}" >
      <fileset dir="${src.java.dir}/server" 
               includes="org/openejb/client/LocalInitialContextFactory.java"
               excludes="**/CVS/**,**/*.class" />
    </copy>
    
    <copy todir="${build.openejb.src}" >
      <fileset dir="${src.java.dir}/facilities" 
               includes="org/openejb/loader/**"
               excludes="**/CVS/**,**/*.class" />
    </copy>
  </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>

    <replace file="${build.openejb.dest}/MANIFEST.MF" token="$$VERSION$$" value="${version}"/>
  
  </target>
  
  <!-- ================================================================== -->
  <!-- Compiles the source directory                                      -->
  <!-- ================================================================== -->
  
  <target name="compile" description="--> compiles the java source files">
    <javac srcdir="${build.openejb.src}"
           destdir="${build.openejb.dest}"
           classpathref="project.classpath"
           debug="${debug}"
           deprecation="${deprecation}">
      
      <classpath>
        <path refid="project.classpath"/>
        <pathelement location="${build.dest}/openejb"/>
      </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="dist/${project}_loader-${version}.jar"
         basedir="${build.openejb.dest}"
         includes="**/*.class"
         excludes="**/*Servlet.class"
         manifest="${build.openejb.dest}/MANIFEST.MF"/>
          
    <copy file="${build.openejb.src}/org/openejb/loader/web.xml"
         tofile="${build.openejb.dest}/web.xml" />
    
    <replace file="${build.openejb.dest}/web.xml" token="$$VERSION$$" value="${version}"/>

    <war warfile="dist/${project}_loader-${version}.war"
         webxml="${build.openejb.dest}/web.xml">
        <fileset dir="${build.openejb.src}/org/openejb/loader/">
          <include name="**/*.jsp"/>
          <exclude name="**/*.java"/>
        </fileset>
        <fileset dir="${build.openejb.dest}">
          <include name="images/*.gif"/>
          <include name="*.html"/>
          <include name="*.css"/>
        </fileset>
         <classes dir="${build.openejb.dest}">
          <include name="**/*Servlet.class"/>
         </classes>
         <lib dir="dist/">
          <include name="${project}_loader-${version}.jar"/>
        </lib>
      </war>          
  </target>
  
  <!-- ================================================================== -->
  <!-- Creates the API documentation                                      -->
  <!-- ================================================================== -->
  
  <target name="javadocs"
          depends="compile"
          description="--> generates the API documentation">
          
  </target>
  
</project>
