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

  <!-- Give user a chance to override without editing this file
       (and without typing -D each time they invoke a target) -->

  <!-- Allow any user specific values to override the defaults -->
  <property file="${user.home}/build.properties" />

  <!-- Set default values for the build -->
  <property file="src/build.properties" />

  <property name="build.src" value="${build.dir}/src"/>
  <property name="build.dest" value="${build.dir}/classes"/>
  <property name="src.java.dir" value="${src.dir}"/>
  <property name="src.doc.dir" value="${docs.src}"/>
  <property name="dest.doc.dir" value="${docs.dest}"/>
  <property name="dest.javadoc.dir" value="${javadoc.destdir}"/>
  <property name="final.name" value="${project}-${version}"/>
  <property name="final.dir" value="dist/${final.name}/"/>
  <property name="reports.tests.dir" value="test/reports"/>
  
  <!-- these jars are for the test target -->
  
  <property name="proxy.factory.jar" value="dist/${project}-${version}.jar"/>
  <property name="client.testrunner.jar" value="dist/${project}_testsuite-${version}.jar"/>
  
  <!-- 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="${xalan.jar}"/>
  </path>
  
  <!-- Build classpath for test cases -->     
  <path id="project.test.classpath">
    <path refid="project.classpath"/>
    <pathelement path="${build.dest}/testsuite"/>
    <pathelement path="${build.dest}/openejb"/>
    <pathelement location="${proxy.factory.jar}"/>
    <pathelement location="${client.testrunner.jar}"/>
    <fileset dir="dist">
      <include name="${project}*-${version}.jar"/>
    </fileset>
  </path>

  <!-- ================================================================== -->
  <!-- Task definition for the JRefactory pretty printer                  -->
  <!--                                                                    -->
  <!-- You have to uncomment this section if you want to use this         -->
  <!-- feature!                                                           -->
  <!-- ================================================================== -->
  
  <!--                                                                           
  <taskdef name="pretty" classname="org.acm.seguin.ant.Pretty">
    <classpath>
      <path refid="project.classpath"/>
    </classpath>
  </taskdef>
  -->
  
  <!-- ================================================================== -->
  <!-- Prints useful build environment values                             -->
  <!-- ================================================================== -->
  
  <target name="env" depends="check_available">
    <tstamp/>
<!--
    <echo message="version                = ${version}"/>
    <echo message="DSTAMP                 = ${DSTAMP}"/>
    <echo message="TSTAMP                 = ${TSTAMP}"/>

    <echo message="java.home              = ${java.home}"/>
    <echo message="user.home              = ${user.home}"/>   

    <echo message="jrefactory.jar         = ${jrefactory.jar}"/>
    <echo message="castor.jar             = ${castor.home}/${castor.jar}"/>
    <echo message="castor.xml.jar         = ${castor.home}/${castor.xml.jar}"/>
    <echo message="ejb11.jar              = ${ejb11.jar}"/>
    <echo message="ejb20.jar              = ${ejb20.jar}"/>
    <echo message="jaas.jar               = ${jaas.home}/${jaas.jar}"/>
    <echo message="jca.jar                = ${jca.jar}"/>
    <echo message="jdbcext.jar            = ${jdbcext.jar}"/>
    <echo message="jdk12proxy.jar         = ${jdk12proxy.jar}"/>
    <echo message="jedi.jar               = ${jedi.home}/lib/${jedi.jar}"/>
    <echo message="jediplugin.jar         = ${jedi.home}/lib/${jediplugin.jar}"/>
    <echo message="jms.jar                = ${jms.jar}"/>
    <echo message="jndi.jar               = ${jndi.jar}"/>
    <echo message="jta.jar                = ${jta.jar}"/>
    <echo message="log4j.jar              = ${log4j.jar}"/>
    <echo message="minerva.jar            = ${minerva.jar}"/>
    <echo message="openorb.jar            = ${openorb.home}/${openorb.jar}"/>
    <echo message="openorb.rmi.jar        = ${openorb.home}/${openorb.rmi.jar}"/>
    <echo message="openorb.tools.jar      = ${openorb.home}/${openorb.tools.jar}"/>
    <echo message="jts.jar                = ${jts.jar}"/>
    <echo message="tyrex.jar              = ${tyrex.home}/${tyrex.jar}"/>
    <echo message="tyrex.iiop.jar         = ${tyrex.home}/${tyrex.iiop.jar}"/>
    <echo message="jaxp.jar               = ${jaxp.home}/jaxp.jar"/>
    <echo message="jaxp.parser.jar        = ${jaxp.home}/${jaxp.parser.jar}"/>
    <echo message="jaxp.xsltprocessor.jar = ${jaxp.home}/${jaxp.xsltprocessor.jar}"/>
    <echo message="jaxp.xalan1compat.jar  = ${jaxp.home}/${jaxp.xalan1compat.jar}"/>
    <echo message="junit.jar              = ${junit.jar}"/>
    <echo message="jakarta.regexp.jar     = ${jakarta.regexp.jar}"/>
    <echo message="xalan.jar              = ${xalan.jar}"/>    
-->  
  </target>

  <!-- ================================================================== -->
  <!-- Help on usage                                                      -->
  <!-- ================================================================== -->
  
  <target name="usage">
    <echo message="use -projecthelp to see the available targets"/>
  </target>
  
  <target name="targets">
    <echo message="use -projecthelp to see the available targets"/>
  </target>
  
  <!-- ================================================================== -->
  <!-- Check to see what optional dependencies are available              -->
  <!-- ================================================================== -->
  
  <target name="check_available">
    
    <available 
      classname="org.acm.seguin.ant.Pretty"
      property="jrefactory.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.exolab.castor.jdo.JDO"
      property="castor.present"
      classpathref="project.classpath"
    />
    
    <available 
      file="${ejb11.jar}"
      property="ejb11.present"
      classpathref="project.classpath"
    />
  
    <available 
      classname="javax.ejb.MessageDrivenBean"
      property="ejb20.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="javax.ejb.MessageDrivenBean"
      property="ejb20.present"
      classpathref="project.classpath"
    />    
    
    <available 
      classname="javax.security.auth.Subject"
      property="jaas.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="javax.resource.cci.Connection"
      property="jca.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="javax.sql.DataSource"
      property="jdbcext.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.opentools.proxies.Proxy"
      property="jdk12proxy.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.opentools.deployer.gui.MainPanel"
      property="jedi.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.opentools.deployer.plugins.j2ee12.J2ee12Plugin"
      property="jediplugin.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="javax.jms.Message"
      property="jms.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="javax.naming.Name"
      property="jndi.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="javax.transaction.Transaction"
      property="jta.present"
      classpathref="project.classpath"
    />    
    
    <available 
      classname="org.apache.log4j.Category"
      property="log4j.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.opentools.minerva.connector.PoolManager"
      property="minerva.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.omg.CORBA.Context"
      property="openorb.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.openorb.rmi.DefaultORB"
      property="openorb.rmi.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.openorb.compiler.IdlCompiler"
      property="openorb.tools.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.omg.CosTransactions.TransactionFactory"
      property="jts.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="tyrex.tm.impl.TransactionImpl"
      property="tyrex.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="tyrex.corba.OTSServer"
      property="tyrex.iiop.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="javax.xml.parsers.SAXParser"
      property="jaxp.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.xml.sax.Parser"
      property="jaxp.parser.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.apache.xalan.processor.TransformerFactoryImpl"
      property="jaxp.xsltprocessor.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.apache.xalan.xslt.XSLTProcessor"
      property="jaxp.xalan1compat.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="junit.framework.Test"
      property="junit.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.apache.regexp.RE"
      property="jakarta.regexp.present"
      classpathref="project.classpath"
    />
    
    <available 
      classname="org.apache.xalan.Version"
      property="xalan.present"
      classpathref="project.classpath"
    />
    
    <available
      property="jdk12"
      classname="java.util.Map"
      classpathref="project.classpath"
    />
    
	<available
      property="jdk13"
      classname="java.lang.reflect.Proxy"
      classpathref="project.classpath"
    />
    
  </target>  
  
  <!-- uncomment this section if you wanna use the pretty printer -->
  
  <!--
  <target name="check.jrefactory" unless="jrefactory.present">
    <antcall target="property-warning">
      <param name="name" value="jrefactory.jar"/>
      <param name="value" value="${jrefactory.jar}"/>
    </antcall>
  </target>
  -->
  
  <target name="check.castor" unless="castor.present">
    <antcall target="property-warning">
      <param name="name" value="castor.jar"/>
      <param name="value" value="${castor.home}/dist/${castor.jar}"/>
    </antcall>
  </target>
  
  <target name="check.ejb11" unless="ejb11.present">
    <antcall target="property-warning">
      <param name="name" value="ejb11.jar"/>
      <param name="value" value="${ejb11.jar}"/>
    </antcall>
  </target>
                                          
  <target name="check.ejb20" unless="ejb20.present">
    <antcall target="property-warning">
      <param name="name" value="ejb20.jar"/>
      <param name="value" value="${ejb20.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jaas" unless="jaas.present">
    <antcall target="property-warning">
      <param name="name" value="jaas.jar"/>
      <param name="value" value="${jaas.home}/lib/${jaas.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jca" unless="jca.present">
    <antcall target="property-warning">
      <param name="name" value="jca.jar"/>
      <param name="value" value="${jca.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jdbcext" unless="jdbcext.present">
    <antcall target="property-warning">
      <param name="name" value="jdbcext.jar"/>
      <param name="value" value="${jdbcext.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jdk12proxy" unless="jdbcext.present">
    <antcall target="property-warning">
      <param name="name" value="jdk12proxy.jar"/>
      <param name="value" value="${jdk12proxy.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jedi" unless="jedi.present">
    <antcall target="property-warning">
      <param name="name" value="jedi.jar"/>
      <param name="value" value="${jedi.home}/lib/${jedi.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jediplugin" unless="jediplugin.present">
    <antcall target="property-warning">
      <param name="name" value="jediplugin.jar"/>
      <param name="value" value="${jedi.home}/lib/${jediplugin.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jms" unless="jms.present">
    <antcall target="property-warning">
      <param name="name" value="jms.jar"/>
      <param name="value" value="${jms.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jndi" unless="jndi.present">
    <antcall target="property-warning">
      <param name="name" value="jndi.jar"/>
      <param name="value" value="${jndi.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jta" unless="jta.present">
    <antcall target="property-warning">
      <param name="name" value="jta.jar"/>
      <param name="value" value="${jta.jar}"/>
    </antcall>
  </target>
  
  <target name="check.log4j" unless="log4j.present">
    <antcall target="property-warning">
      <param name="name" value="log4j.jar"/>
      <param name="value" value="${log4j.jar}"/>
    </antcall>
  </target>
  
  <target name="check.minerva" unless="minerva.present">
    <antcall target="property-warning">
      <param name="name" value="minerva.jar"/>
      <param name="value" value="${minerva.jar}"/>
    </antcall>
  </target>
  
  <target name="check.openorb" unless="openorb.present">
    <antcall target="property-warning">
      <param name="name" value="openorb.jar"/>
      <param name="value" value="${openorb.home}/${openorb.jar}"/>
    </antcall>
  </target>
  
  <target name="check.openorb.rmi" unless="openorb.rmi.present">
    <antcall target="property-warning">
      <param name="name" value="openorb.rmi.jar"/>
      <param name="value" value="${openorb.home}/${openorb.rmi.jar}"/>
    </antcall>
  </target>
  
  <target name="check.openorb.tools" unless="openorb.tools.present">
    <antcall target="property-warning">
      <param name="name" value="openorb.tools.jar"/>
      <param name="value" value="${openorb.home}/${openorb.tools.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jts" unless="jts.present">
    <antcall target="property-warning">
      <param name="name" value="jts.jar"/>
      <param name="value" value="${jts.jar}"/>
    </antcall>
  </target>
  
  <target name="check.tyrex" unless="tyrex.present">
    <antcall target="property-warning">
      <param name="name" value="tyrex.jar"/>
      <param name="value" value="${tyrex.home}/dist/${tyrex.jar}"/>
    </antcall>
  </target>
  
  <target name="check.tyrex.iiop" unless="tyrex.iiop.present">
    <antcall target="property-warning">
      <param name="name" value="tyrex.iiop.jar"/>
      <param name="value" value="${tyrex.home}/dist/${tyrex.iiop.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jaxp" unless="jaxp.present">
    <antcall target="property-warning">
      <param name="name" value="jaxp.jar"/>
      <param name="value" value="${jaxp.home}/jaxp.jar"/>
    </antcall>
  </target>
  
  <target name="check.jaxp.parser" unless="jaxp.parser.present">
    <antcall target="property-warning">
      <param name="name" value="jaxp.parser.jar"/>
      <param name="value" value="${jaxp.home}/${jaxp.parser.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jaxp.xsltprocessor" unless="jaxp.xsltprocessor.present">
    <antcall target="property-warning">
      <param name="name" value="jaxp.xsltprocessor.jar"/>
      <param name="value" value="${jaxp.home}/${jaxp.xsltprocessor.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jaxp.xalan1compat" unless="jaxp.xalan1compat.present">
    <antcall target="property-warning">
      <param name="name" value="jaxp.xalan1compat.jar"/>
      <param name="value" value="${jaxp.home}/${jaxp.xalan1compat.jar}"/>
    </antcall>
  </target>
  
  <target name="check.junit" unless="junit.present">
    <antcall target="property-warning">
      <param name="name" value="junit.jar"/>
      <param name="value" value="${junit.jar}"/>
    </antcall>
  </target>
  
  <target name="check.jakarta.regexp" unless="jakarta.regexp.present">
    <antcall target="property-warning">
      <param name="name" value="jakarta.regexp.jar"/>
      <param name="value" value="${jakarta.regexp.jar}"/>
    </antcall>
  </target>
  
  <target name="check.xalan" unless="xalan.present">
    <antcall target="property-warning">
      <param name="name" value="xalan.jar"/>
      <param name="value" value="${xalan.jar}"/>
    </antcall>
  </target>
  
  <!-- ================================================================== -->
  <!-- Print a requirement waring if a requirement check fails            -->
  <!-- ================================================================== -->
  
  <target name="property-warning">
    <echo>
      +----------------------------------------------------------------+
      + F A I L E D  R E Q U I R E M E N T                             |
      +----------------------------------------------------------------+
      | You must define the following property in order                |
      | to build OpenEJB:                                              |
      |                                                                |
      | ${name} = ${value}
      |                                                                |
      | You can set this property in the provided build.properties     |
      | file, or you may set this property in your                     |
      | ${user.home}/build.properties file.                            
      +----------------------------------------------------------------+
    </echo>
    <fail message="Failed Requirement"/>
  </target>
  
  <!-- ================================================================== -->
  <!-- Prepares the build directory                                       -->
  <!--                                                                    -->
  <!-- You have to include the dependency 'check.jrefactory' if you       -->
  <!-- wanna use the pretty printer.                                      -->
  <!-- ================================================================== -->
  
  <target name="prepare"
          depends="env,
                   check.castor,
                   check.ejb11,
                   check.ejb20,
                   check.jaas,
                   check.jca,
                   check.jdbcext,
                   check.jdk12proxy,
                   check.jedi,
                   check.jediplugin,
                   check.jms,
                   check.jndi,
                   check.jta,
                   check.log4j,
                   check.minerva,
                   check.openorb,
                   check.openorb.rmi,
                   check.openorb.tools,
                   check.jts,
                   check.tyrex,
                   check.tyrex.iiop,
                   check.jaxp,
                   check.jaxp.parser,
                   check.junit,
                   check.jakarta.regexp,
                   check.xalan"
          description="--> prepares the build environment">
          
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.src}"/>
    <mkdir dir="${build.dest}"/>
    <mkdir dir="${dest.doc.dir}"/>
    <mkdir dir="${dest.javadoc.dir}"/>
    <mkdir dir="./beans"/>
    <mkdir dir="./logs"/>
    
    <style
        style="src/doc/style/changelog.xsl"
        in="${docs.src}/CHANGELOG.xml"
        out="${final.dir}/src/etc/CHANGELOG"
        processor="trax">

    	<param name="version" expression="${version}"/>
    
        <classpath>
            <path refid="project.classpath"/>
        </classpath>
           
    </style>
 
    <antcall target="delegate">
        <param name="target.name" value="prepare"/>
    </antcall>    
          
  </target>
  
  <!-- ================================================================== -->
  <!-- Compiles the source directory                                      -->
  <!-- ================================================================== -->
  
  <target name="compile"
          depends="prepare"
          description="--> compiles the java source files">
                    
    <antcall target="delegate">
        <param name="target.name" value="compile"/>
    </antcall>    
          
          
  </target>
  
  <!-- ================================================================== -->
  <!-- Compiles the source directory and creates a .jar file              -->
  <!-- ================================================================== -->
  
  <target name="jar"
          depends="compile"
          description="--> generates all java archives (default)">
          
    <antcall target="delegate">
        <param name="target.name" value="jar"/>
    </antcall>    
          
          
  </target>
  
  <!-- ================================================================== -->
  <!-- Creates the API documentation                                      -->
  <!-- ================================================================== -->
  
  <target name="javadocs"
          depends="compile"
          description="--> generates the API documentation">
          
    <copy todir="build/src/javadoc">
        <fileset dir="src/main" includes="**/**.java,**/**.html" excludes="**/CVS/**"/>
        <fileset dir="src/facilities" includes="**/**.java,**/**.html" excludes="**/modern/**,**/ui/**,**/sp/**,**/CVS/**"/>
    </copy>
    
    <mkdir dir="${docs.dest}/html/apidocs"/>
          
    <javadoc packagenames="org.openejb.*"
             sourcepath="build/src/javadoc"
             destdir="${docs.dest}/html/apidocs"
             doctitle="${name} JavaDoc"
             windowtitle="${name} JavaDoc"
		     package="true"
		     author="true"
             version="true"
             noindex="true"
             classpathref="project.classpath">
          
    <bottom><![CDATA[
        <table width="100%" cellspacing="0" cellpadding="1" border="0">
          <tr>
            <td><img src="http://openejb.sourceforge.net/images/logo_ejb.gif"></td>
            <td align="right"><img src="http://sourceforge.net/sflogo.php?group_id=44351&amp;type=2" width="125" height="37" border="0"></td>
          </tr>
          <tr bgcolor="#7270c2">
            <td><font face="Arial" color="#FFFFFF">Copyright &#169; 2002 OpenEJB Group. All Rights Reserved.</font></td>
            <td align="right"><font face="Arial" color="#FFFFFF"><a href="http://openejb.sourceforge.net">http://openejb.sourceforge.net</a></font></td>
          </tr>
        </table> 
    ]]></bottom>

    </javadoc>
           
  </target>
  
  <!-- ================================================================== -->
  <!-- Creates the OpenEJB documentation                                  -->
  <!-- ================================================================== -->
  
  <target name="docs"
          depends="prepare"
          description="--> generates documentation from XML files via XSLT">

    <copy todir="${docs.dest}/html/spec">
        <fileset dir="${docs.src}/spec" />
    </copy>
    
    <style basedir="${docs.src}" 
        destdir="${docs.dest}/html" 
        style="src/doc/style/sysdesign.xsl"
        includes="**/design_*.xml" 
        excludes="style/**,src/doc/faq**,project.xml,CHANGELOG.xml,download.xml,release-plan.xml"
        processor="trax">           
      
        <classpath>
            <path refid="project.classpath"/>
        </classpath>
    </style>
    
	<style basedir="${docs.src}" 
		destdir="${docs.dest}/html" 
		style="src/doc/style/faq.xsl"
		includes="**/faq*.xml" 
		excludes="style/**,project.xml,CHANGELOG.xml,download.xml,release-plan.xml"
		processor="trax">           

		<classpath>
			<path refid="project.classpath"/>
		</classpath>
	</style>

    <style basedir="${docs.src}" 
        destdir="${docs.dest}/html" 
        style="src/doc/style/website.xsl"
        includes="**/**.xml" 
        excludes="style/**,src/doc/design_**,src/doc/faq**,project.xml,CHANGELOG.xml,download.xml,release-plan.xml"
        processor="trax">           
      
        <classpath>
            <path refid="project.classpath"/>
        </classpath>           
    </style>
    
    <style style="src/doc/style/download.xsl"
        in="${docs.src}/CHANGELOG.xml" 
        out="${docs.dest}/html/download.html" 
        processor="trax">           
      
        <classpath>
            <path refid="project.classpath"/>
        </classpath>           
    </style>
    
    <style style="src/doc/style/release-plan.xsl"
        in="${docs.src}/CHANGELOG.xml" 
        out="${docs.dest}/html/release-plan.html" 
        processor="trax">           
      
        <classpath>
            <path refid="project.classpath"/>
        </classpath>           
    </style>

    <style style="src/doc/style/release-notes.xsl"
        in="${docs.src}/CHANGELOG.xml" 
        out="${docs.dest}/release-notes.html" 
        processor="trax">           
      
        <classpath>
            <path refid="project.classpath"/>
        </classpath>           
    </style>

    <style style="src/doc/style/change-notes.xsl"
        in="${docs.src}/CHANGELOG.xml" 
        out="${docs.dest}/change-notes.html" 
        processor="trax">           
      
        <classpath>
            <path refid="project.classpath"/>
        </classpath>           
    </style>

    <copy todir="${docs.dest}/html/images">
        <fileset dir="${docs.src}/images" />
    </copy>
    <copy todir="${docs.dest}/html/images">
        <fileset dir="${docs.src}/style/images" includes="*.gif"/>
    </copy>
    <copy todir="${docs.dest}/html/">
        <fileset dir="${docs.src}/style" includes="*.css"/>
    </copy>
    <copy todir="${docs.dest}/html">
        <fileset dir="${docs.src}" includes="license.txt,document.dtd,*.pdf,*.java,faq_template.xml"/> 
    </copy> 
    <copy todir="${docs.dest}/html">
        <fileset dir="${docs.src}" includes="*.ppt"/>
    </copy>
  </target>

  
  <!-- ================================================================== -->
  <!-- Cleans up the build directory                                      -->
  <!-- ================================================================== -->
  
  <target name="clean"
          description="--> cleans up the build directory">
    <delete dir="${build.dir}"/>
    <delete dir="${dest.doc.dir}"/>
    <delete dir="dist"/>
    <delete dir="${reports.tests.dir}"/>
  </target>
  
  <!-- ================================================================== -->
  <!-- Beautifies the whole java source code                              -->
  <!--                                                                    -->
  <!-- Uncomment this section if you wanna use the pretty printer         -->
  <!-- ================================================================== -->
  
  <!--
  <target name="beautify">
  
    <pretty settingsDir="${user.home}" cvs="true">
 	  <fileset dir="${src.java.dir}">
	    <include name="**/*.java" />
	  </fileset>
    </pretty>
  
  </target>
  -->
  
  <!-- ================================================================== -->
  <!-- T E S T S                                                          -->
  <!-- ================================================================== -->

  <target name="prepare-test"
          depends="check_test_available,
                   check.proxy.factory,
                   check.client.testrunner,
                   jar"
  />
  
  <target name="check_test_available">
    
    <available 
      classname="org.openejb.util.proxy.ProxyFactory"
      property="proxy.factory.present"
      classpathref="project.test.classpath"
    />
    
    <available 
      classname="org.openejb.test.TestRunner"
      property="client.testrunner.present"
      classpathref="project.test.classpath"
    />
    
  </target>
  
  <target name="check.proxy.factory" unless="proxy.factory.present">
    <antcall target="property-warning">
      <param name="name" value="proxy.factory.jar"/>
      <param name="value" value="${proxy.factory.jar}"/>
    </antcall>
  </target>
  
  <target name="check.client.testrunner" unless="client.testrunner.present">
    <antcall target="property-warning">
      <param name="name" value="client.testrunner.jar"/>
      <param name="value" value="${client.testrunner.jar}"/>
    </antcall>
  </target>
  
  <target name="test-runner">

    <java classname="org.openejb.test.TestRunner" fork="true">
      <jvmarg value="-Dopenejb.testsuite.properties=${testsuite.properties}"/>
      <jvmarg value="-Dopenejb.test.server=${test.server}"/>
      <jvmarg value="-Dopenejb.test.database=org.openejb.test.InstantDbTestDatabase"/>
      <jvmarg value="-Dopenejb.home=${basedir}"/>
      <arg line="org.openejb.test.ClientTestSuite"/> 
      <classpath refid="project.test.classpath"/>
    </java>

  </target>

  <target name="test.local"
          depends="prepare-test"
          description="--> runs OpenEJB Local Server (aka IntraVM Server) unit tests"
          if="junit.present">
    
    <antcall target="test-runner">
      <param name="testsuite.properties" value="src/tests-ejb/IvmServer_config.properties"/>
      <param name="test.server" value="org.openejb.test.IvmTestServer"/>
    </antcall>
  
  </target>

  <target name="test.remote"
          depends="prepare-test"
          description="--> runs OpenEJB Remote Server unit tests"
          if="junit.present">
    
    <antcall target="test-runner">
      <param name="testsuite.properties" value="src/tests-ejb/RemoteServer_config.properties"/>
      <param name="test.server" value="org.openejb.test.RemoteTestServer"/>
    </antcall>
  
  </target>

  <target name="test"
          depends="prepare-test,
                   test.local,
                   test.remote"
          description="--> runs OpenEJB unit tests"
          if="junit.present">
  </target>
  
  <!-- ================================================================== -->
  <!-- Creates distribution packages (*.tar.gz and *.zip files)           -->
  <!-- ================================================================== -->
  
  <target name="package"
          depends="jar, javadocs, docs, package.zip, package.tar.gz"
          description="--> archives all files as a complete OpenEJB distribution package"/>
          
  <target name="prepare-package">
    <mkdir dir="${final.dir}"/>
    <mkdir dir="${final.dir}/bin"/>
    <mkdir dir="${final.dir}/conf"/>
    <mkdir dir="${final.dir}/docs"/>
    <mkdir dir="${final.dir}/lib"/>
    <mkdir dir="${final.dir}/dist"/>
    <mkdir dir="${final.dir}/src"/>
    <mkdir dir="${final.dir}/beans"/>
    <mkdir dir="${final.dir}/logs"/>
  
    <!-- copy required jar files -->               
    <copy todir="${final.dir}/dist">
    
      <fileset dir="dist" >
        <include name="openejb-${version}.jar"/>
        <include name="openejb_client-${version}.jar"/>
        <include name="openejb_server-${version}.jar"/>
        <include name="openejb_loader-${version}.war"/>
        <include name="openejb_loader-${version}.jar"/>
        <include name="openejb_ejb_tests-${version}.jar"/>
      </fileset>
    
    </copy>
    
    <!-- copy required jar files -->               
    <copy todir="${final.dir}/beans">
      <fileset dir="dist" >
        <include name="openejb_ejb_tests-${version}.jar"/>
      </fileset>
    </copy>
  
    <!-- copy OpenEJB jar files -->               
    <copy todir="${final.dir}/lib">
    
      <fileset dir="lib" >
        <include name="*.jar"/>
      </fileset>
    
    </copy>
    
    <!-- copy documentation files -->               
    <copy todir="${final.dir}/docs">
    
      <fileset dir="docs/html" >
        <include name="**/**"/>
        <exclude name="**/OpenEJB_Specification.doc"/>
        <exclude name="**/OpenEJB_Specification.ps"/>
      </fileset>
    
    </copy>
    
    <!-- copy source files -->               
    <copy todir="${final.dir}/src">
    
      <fileset dir="src" >
        <include name="**/**"/>
        <exclude name="**/ObjectAA"/>
        <exclude name="**/ObjectBB"/>
        <exclude name="**/ObjectCC"/>
        <exclude name="**/ObjectDD"/>
      </fileset>
    
    </copy>

    <!-- copy configuration files -->
    <copy todir="${final.dir}/conf">
    
      <fileset dir="conf" >
        <include name="default.cmp_global_tx_database.xml"/>
        <include name="default.cmp_local_tx_database.xml"/>
        <include name="default.cmp_mapping.xml"/>
        <include name="default.idb_database.conf"/>
        <include name="default.logging.conf"/>
        <include name="default.openejb.conf"/>
        <include name="default.service-jar.xml"/>
        <include name="postgresql.*"/>
        <include name="instantdb.*"/>
      </fileset>
    
    </copy>
    
    <!-- copy configuration files -->
    <copy file="conf/default.openejb.conf" tofile="${final.dir}/conf/openejb.conf" />
    
    <!-- copy shel/batch files -->
    <copy todir="${final.dir}/bin">
    
      <fileset dir="bin/" >
        <include name="*.sh"/>
        <include name="*.bat"/>
        <include name="*.txt"/>
      </fileset>
    
    </copy>
    
    <chmod dir="${final.dir}/bin" perm="ugo+rx" includes="**/*.sh"/>
  
    <!-- copy shel/batch files -->
    <copy todir="${final.dir}">
    
      <fileset dir="./" >
        <include name="openejb.sh"/>
        <include name="openejb.bat"/>
      </fileset>
    
    </copy>
    
    <chmod dir="${final.dir}" perm="ugo+rx" includes="**/*.sh"/>
    
    <fixcrlf srcdir="${final.dir}" eol="lf" eof="remove" includes="**/*.sh" />

  
    <copy todir="${final.dir}">
    
      <fileset dir="src/etc" >
        <include name="README"/>
        <include name="LICENSE"/>
        <include name="CREDITS"/>
      </fileset>
    
    </copy>
  
  </target>
  
  <target name="package.zip" depends="prepare-package">
  
    <!-- create a zip file containing the whole OpenEJB dist -->
    <zip zipfile="dist/${project}-${version}.zip">
      <zipfileset dir="${final.dir}"
      			  prefix="./${project}-${version}" />
    </zip>
    
    <!-- create a zip file containing just jar files -->
    <zip zipfile="dist/${project}-${version}-lib.zip">
      <zipfileset dir="${final.dir}/lib"
      			  prefix="./${project}-${version}/lib" />
    </zip>
    
    <!-- create a zip file containing just documentation files -->
    <zip zipfile="dist/${project}-${version}-doc.zip">
      <zipfileset dir="${final.dir}/docs"
      			  prefix="./${project}-${version}/docs" />
    </zip>
  
  </target>

  <target name="package.tar.gz" depends="prepare-package">
    <!-- create a zip file containing the whole OpenEJB dist -->
    <tar tarfile="dist/${project}-${version}.tar">
      <tarfileset dir="${final.dir}/.." mode="755">
        <include name="**/**.sh"/>
      </tarfileset>
      <tarfileset dir="${final.dir}/..">
        <include name="${project}-${version}/**"/>
        <exclude name="**/**.sh"/>
      </tarfileset>
    </tar>
  
    <gzip zipfile="dist/${project}-${version}.tar.gz"
          src="dist/${project}-${version}.tar"/>
    
    <!-- create a zip file containing just jar files -->
    <tar tarfile="dist/${project}-${version}-lib.tar">
      <tarfileset dir="${final.dir}/lib"/>
    </tar>
    
    <gzip zipfile="dist/${project}-${version}-lib.tar.gz"
          src="dist/${project}-${version}-lib.tar"/>
    
    <!-- create a zip file containing just documentation files -->
    <tar tarfile="dist/${project}-${version}-doc.tar">
      <tarfileset dir="${final.dir}/docs"/>
    </tar>
    
    <gzip zipfile="dist/${project}-${version}-doc.tar.gz"
          src="dist/${project}-${version}-doc.tar"/>
  
  </target>

  <target name="delegate">
  
    <antcall target="pre-delegate">
        <param name="module" value="openejb"/>
    </antcall>    
    
    <antcall target="pre-delegate">
        <param name="module" value="openejb-loader"/>
    </antcall>    
    
    <antcall target="pre-delegate">
        <param name="module" value="openejb-server"/>
    </antcall>    

<!--    
    <antcall target="pre-delegate">
        <param name="module" value="corba"/>
    </antcall>    
    
    <antcall target="pre-delegate">
        <param name="module" value="ri-client"/>
    </antcall>    
    
    <antcall target="pre-delegate">
        <param name="module" value="ri-server"/>
    </antcall>    
-->    
    <antcall target="pre-delegate">
        <param name="module" value="testsuite"/>
    </antcall>    
    
    <antcall target="pre-delegate">
        <param name="module" value="unit-tests"/>
    </antcall>    

  </target>
  
  <target name="pre-delegate">
    <available
      property="build-${module}.present"
      file="src/build-${module}.xml"
    />
    
    <antcall target="post-delegate" />
  </target>

  <target name="post-delegate" if="build-${module}.present">
    <echo message="${target.name}   ${module}"/>
    
    <ant antfile="src/build-${module}.xml" target="${target.name}">
      <property file="build.properties"/>
      
      <property name="build.src" value="${build.src}"/>
      <property name="build.dest" value="${build.dest}"/>
      <property name="src.java.dir" value="${src.java.dir}"/>
      <property name="src.doc.dir" value="${src.doc.dir}"/>
      <property name="dest.doc.dir" value="${dest.doc.dir}"/>
      <property name="dest.javadoc.dir" value="${dest.javadoc.dir}"/>
      <property name="final.name" value="${final.name}"/>
      <property name="final.dir" value="${final.dir}/"/>
    </ant>
  </target>
  
</project>
