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

  <property name="build.riclient.src" value="${build.src}/riclient"/>
  <property name="build.riclient.dest" value="${build.dest}/riclient"/>
  <property name="dest.riclient.javadoc.dir" value="${dest.javadoc.dir}/riclient"/>
  
  <!-- 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}"/>
  </path>
  
  
  <!-- ================================================================== -->
  <!-- Prepares the build directory                                       -->
  <!-- ================================================================== -->

  <target name="prepare">
  
    <mkdir dir="${build.riclient.src}"/>
    <mkdir dir="${build.riclient.dest}"/>
    <mkdir dir="${dest.riclient.javadoc.dir}"/>
    
    <copy todir="${build.riclient.src}">
    
      <fileset dir="${src.java.dir}/facilities" >
        <include name="${src.java.dir}/facilities/org/openejb/alt/util/Messages.java"/>
        <include name="**/ri/**"/>
        <exclude name="**/CVS/**"/>
        <exclude name="**/*.class"/>
      </fileset>
    
    </copy>
    
  </target>
  
  <target name="copy.manifest">
  
    <copy todir="${build.riclient.dest}">
    
      <fileset dir="${src.java.dir}/etc" >
        <include name="**/LICENSE"/>
        <include name="**/MANIFEST.MF"/>
        <include name="**/README"/>
      </fileset>
    
    </copy>
        
	<copy todir="${build.riclient.dest}">

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

	</copy>

    <replace file="${build.riclient.dest}/MANIFEST.MF" token="$$VERSION$$" value="${version}"/>
  
  </target>
  
    <target name="copy.i18n">
    
      <copy todir="${build.riclient.dest}">
      
        <fileset dir="${src.java.dir}/facilities" >
          <include name="**/resources/*.properties"/>
        </fileset>
      
      </copy>
    
    </target>

  <!-- ================================================================== -->
  <!-- Compiles the source directory                                      -->
  <!-- ================================================================== -->
  
  <target name="compile"
          depends="prepare"
          description="--> compiles the java source files">
          
    <javac srcdir="${build.riclient.src}"
           destdir="${build.riclient.dest}"
           debug="${debug}"
           deprecation="${deprecation}">
             
      <include name="org/openejb/ri/server/AuthenticationRequest.java"/>
      <include name="org/openejb/ri/server/DynamicContext.java"/>
      <include name="org/openejb/ri/server/RiClassLoader.java"/>
      <include name="org/openejb/ri/server/RiInitCtxFactory.java"/>
      <exclude name="**/spi/**"/>

      <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, copy.i18n"
          description="--> generates all java archives (default)">
          
    <jar jarfile="dist/${project}_ri_client-${version}.jar"
         basedir="${build.riclient.dest}"
         manifest="${build.riclient.dest}/MANIFEST.MF"/>
          
  </target>
  
  <!-- ================================================================== -->
  <!-- Creates the API documentation                                      -->
  <!-- ================================================================== -->
  
  <target name="javadocs"
          depends="compile"
          description="--> generates the API documentation">
          
    <javadoc packagenames="org.openejb.*"
             sourcepath="${build.riclient.src}"
             destdir="${dest.riclient.javadoc.dir}"
             doctitle="${name} RI-Client 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>
