<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project [
   <!ENTITY buildmagic SYSTEM "../tools/etc/buildmagic/buildmagic.ent">
   <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
   <!ENTITY modules SYSTEM "../tools/etc/buildmagic/modules.ent">
]>

<!-- ====================================================================== -->
<!--                                                                        -->
<!--  JBoss, the OpenSource J2EE webOS                                      -->
<!--                                                                        -->
<!--  Distributable under LGPL license.                                     -->
<!--  See terms of license at http://www.gnu.org.                           -->
<!--                                                                        -->
<!-- ====================================================================== -->

<!-- $Id: build.xml 44809 2006-05-11 14:32:57Z starksm $ -->

<project default="main" name="JBoss/IIOP">

  <!-- ================================================================== -->
  <!-- Setup                                                              -->
  <!-- ================================================================== -->

  <!--
     | Include the common Buildmagic elements.
     |
     | This defines several different targets, properties and paths.
     | It also sets up the basic extention tasks amoung other things.
   -->

  &buildmagic;


  <!-- ================================================================== -->
  <!-- Initialization                                                     -->
  <!-- ================================================================== -->

  <!--
     | Initialize the build system.  Must depend on '_buildmagic:init'.  
     | Other targets should depend on 'init' or things will mysteriously fail.
   -->

  <target name="init" unless="init.disable" depends="_buildmagic:init">
  </target>


  <!-- ================================================================== -->
  <!-- Configuration                                                      -->
  <!-- ================================================================== -->

  <!--
     | Configure the build system.  
     |
     | This target is invoked by the Buildmagic initialization logic and 
     | should contain module specific configuration elements.
   -->

  <target name="configure" unless="configure.disable">

    <!-- =================== -->
    <!-- Basic Configuration -->
    <!-- =================== -->

    <!-- Module name(s) & version -->
    <property name="module.name" value="jboss-iiop"/>
    <property name="module.Name" value="JBoss IIOP Plugin"/>
    <property name="module.version" value="DEV"/>

    <!-- ========= -->
    <!-- Libraries -->
    <!-- ========= -->

    &libraries;
    <!-- The combined library classpath -->
    <path id="library.classpath">
      <path refid="apache.avalon.classpath"/>
      <path refid="apache.log4j.classpath"/>
      <path refid="junit.junit.classpath"/>
      <path refid="jacorb.jacorb.classpath"/>
      <path refid="oswego.concurrent.classpath"/>
    </path>

    <!-- ======= -->
    <!-- Modules -->
    <!-- ======= -->

    &modules;
    <!-- The combined dependent module classpath -->
    <path id="dependentmodule.classpath">
      <path refid="jboss.j2ee.classpath"/>
      <path refid="jboss.common.classpath"/>
      <path refid="jboss.system.classpath"/>
      <path refid="jboss.naming.classpath"/>
      <path refid="jboss.server.classpath"/>
      <path refid="jboss.jmx.classpath"/>
      <path refid="jboss.security.classpath"/>
      <path refid="jboss.transaction.classpath"/>
    </path>

    <!-- ===== -->
    <!-- Tasks -->
    <!-- ===== -->

    <!-- Where source files live -->
    <property name="source.bin" value="${module.source}/bin"/>
    <property name="source.java" value="${module.source}/main"/>
    <property name="source.idl" value="${module.source}/idl"/>
    <property name="source.etc" value="${module.source}/etc"/>
    <property name="source.resources" value="${module.source}/resources"/>

    <!-- Where build generated files will go -->
    <property name="build.bin" value="${module.output}/bin"/>
    <property name="build.classes" value="${module.output}/classes"/>
    <property name="build.lib" value="${module.output}/lib"/>
    <property name="build.api" value="${module.output}/api"/>
    <property name="build.etc" value="${module.output}/etc"/>
    <property name="build.gen-src" value="${module.output}/gen-src"/>
    <property name="build.reports" value="${module.output}/reports"/>
    <property name="build.resources" value="${module.output}/resources"/>

    <!-- Install/Release structure -->
    <property name="install.id" value="${module.name}-${module.version}"/>
    <property name="release.id" value="${install.id}"/>
    <property name="install.root" value="${module.output}/${install.id}"/>

    <!-- The combined thirdparty classpath -->
    <path id="thirdparty.classpath">
      <path refid="library.classpath"/>
      <path refid="dependentmodule.classpath"/>
    </path>

    <!-- RMIC should generate IIOP fluff -->
    <property name="rmic.iiop" value="yes"/>
    <property name="rmic.iiopops" value=""/>

    <!-- classpath and local.classpath must have a value using with a path -->
    <property name="classpath" value=""/>
    <property name="local.classpath" value=""/>

    <!-- The classpath required to build classes. -->
    <path id="javac.classpath">
      <pathelement path="${classpath}"/>
      <pathelement path="${local.classpath}"/>
      <path refid="thirdparty.classpath"/>
    </path>

    <!-- Don't compile SunJDK14IsLocalBugFix if baseclass missing -->
    <condition property="javac.excludes" value="org/jboss/iiop/SunJDK14IsLocalBugFix.java">
      <not>
        <available classname="com.sun.corba.se.internal.iiop.ShutdownUtilDelegate"/>
      </not>
    </condition>
    
    <!-- The classpath required to build javadocs. -->
    <path id="javadoc.classpath">
      <path refid="javac.classpath"/>
    </path>

    <!-- Packages to include when generating api documentation -->
    <property name="javadoc.packages" value="org.jboss.*"/>

    <!-- Override JUnit defaults -->
    <property name="junit.timeout" value="240000"/> <!-- 4 minutes -->
    <property name="junit.batchtest.todir" value="${build.reports}"/>
    <property name="junit.jvm.options" value="-Ddummy"/>
  </target>


  <!-- ================================================================== -->
  <!-- IDL Compilation                                                    -->
  <!-- ================================================================== -->

  <target name="compile-idl" depends="init">
    <taskdef name="jacidl" classname="org.jacorb.idl.JacIDL" classpathref="jacorb.idl.classpath"/>
    <mkdir dir="${build.gen-src}"/>
    <jacidl srcdir="${source.idl}"
      destdir="${build.gen-src}"
      includepath="${jacorb.idl.include}"
      includes="**/TransactionService.idl,**/SASCurrent.idl"/>
    <delete dir="${build.gen-src}/CORBA"/>
  </target>

  <!-- ================================================================== -->
  <!-- Compile                                                            -->
  <!-- ================================================================== -->

  <!-- 
     |  Compile everything.
     |
     |  This target should depend on other compile-* targets for each 
     |  different type of compile that needs to be performed, short of
     |  documentation compiles.
    -->
  <target name="compile"
    depends="compile-classes, compile-rmi, compile-etc, compile-resources"
    description="Compile all source files."/>

  <!-- Compile all class files -->
  <target name="compile-classes" depends="init, compile-idl">

    <mkdir dir="${build.classes}/main"/>

    <javac destdir="${build.classes}/main"
      optimize="${javac.optimize}"
      target="${javac.target}"
      source="${javac.source}"
      debug="${javac.debug}"
      depend="${javac.depend}"
      verbose="${javac.verbose}"
      deprecation="${javac.deprecation}"
      includeAntRuntime="${javac.include.ant.runtime}"
      includeJavaRuntime="${javac.include.java.runtime}"
      includes="${javac.includes}"
      excludes="${javac.excludes}"
      failonerror="${javac.fail.onerror}">
      <src path="${source.java}"/>
      <src path="${build.gen-src}"/>
      <classpath refid="javac.classpath"/>
    </javac>

  </target>

  <!-- Generate IIOP stubs for EJBObject and EJBHome -->

  <target name="compile-rmi" depends="init">

    <!-- Below we use rmic to generate IIOP stubs for the interfaces
         EJBObject and EJBHome. WARNING: do not specify a stubVersion,
         such as 1.2, or else rmic will think we want JRMP stubs, which
         cannot be generated for interfaces! -->

    <rmic base="${build.classes}"
      classname="javax.ejb.EJBObject"
      verify="${rmic.verify}"
      iiop="${rmic.iiop}"
      debug="${rmic.debug}">
      <classpath refid="javac.classpath"/>
    </rmic>

    <rmic base="${build.classes}"
      classname="javax.ejb.EJBHome"
      verify="${rmic.verify}"
      iiop="${rmic.iiop}"
      debug="${rmic.debug}">
      <classpath refid="javac.classpath"/>
    </rmic>

  </target>

  <!-- Compile manifests -->
  <target name="compile-etc" depends="init">
    <mkdir dir="${build.etc}"/>
    <copy todir="${build.etc}" filtering="yes">
      <fileset dir="${source.etc}">
        <include name="**"/>
      </fileset>
    </copy>
  </target>

  <!-- Compile resource files -->
  <target name="compile-resources" depends="init">
    <mkdir dir="${build.resources}"/>
    <copy todir="${build.resources}" filtering="yes">
      <fileset dir="${source.resources}">
        <include name="**/*"/>
      </fileset>
    </copy>
  </target>

  <!-- ================================================================== -->
  <!-- Archives                                                           -->
  <!-- ================================================================== -->

  <!-- 
     | Build all jar files.
   -->

  <target name="jars" description="Build the Service Archive"
    depends="_buildmagic:build-bypass-check"
    unless="build-bypass.on">

    <call target="compile"/>

    <mkdir dir="${build.lib}"/>

    <jar jarfile="${build.lib}/${module.name}.jar"
      manifest="${build.etc}/default.mf">
      <fileset dir="${build.classes}/main">
        <include name="**/jboss/iiop/**"/>
        <include name="**/jboss/invocation/**"/>
        <include name="**/jboss/proxy/**"/>
        <include name="**/jboss/tm/**"/>
        <include name="**/jboss/util/**"/>
      </fileset>
      <fileset dir="${build.classes}">
        <include name="org/omg/stub/javax/ejb/_EJBHome_Stub.class"/>
        <include name="org/omg/stub/javax/ejb/_EJBObject_Stub.class"/>
      </fileset>
    </jar>

    <jar jarfile="${build.lib}/${module.name}-client.jar"
      manifest="${build.etc}/default.mf">
      <fileset dir="${build.classes}/main">
        <include name="**/jboss/iiop/CorbaORB.class"/>
        <include name="**/jboss/iiop/StubClassLoader.class"/>
        <include name="**/jboss/iiop/rmi/*"/>
        <include name="**/jboss/iiop/rmi/marshal/*"/>
        <include name="**/jboss/iiop/rmi/marshal/strategy/StubStrategy.class"/>
        <include name="**/jboss/iiop/rmi/marshal/strategy/StubStrategy$ExceptionReader.class"/>
        <include name="**/jboss/proxy/compiler/**"/>
        <include name="**/jboss/proxy/ejb/DynamicIIOPStub.class"/>
        <include name="**/jboss/proxy/ejb/*ImplIIOP.class"/>
        <include name="**/jboss/proxy/ejb/IIOPHomeFactory.class"/>
        <include name="**/jboss/tm/**"/>
        <exclude name="**/jboss/tm/iiop/TransactionServiceImpl*"/>
        <exclude name="**/jboss/tm/iiop/*POA*"/>
        <include name="**/jboss/util/Log4jLoggerFactory.class"/>
      </fileset>
      <fileset dir="${build.classes}">
        <include name="org/omg/stub/javax/ejb/_EJBHome_Stub.class"/>
        <include name="org/omg/stub/javax/ejb/_EJBObject_Stub.class"/>
      </fileset>
    </jar>

    <mkdir dir="${build.bin}"/>

    <!-- Update the build marker to allow bypassing -->
    <touch file="${build-bypass.marker}"/>

  </target>

  <!-- ================================================================== -->
  <!-- Install & Release                                                  -->
  <!-- ================================================================== -->

  <target name="install"
    description="Install the structure for a release."
    depends="all, _buildmagic:install:default"/>

  <target name="release" depends="install"/>

  <target name="release-zip"
    description="Builds a ZIP distribution."
    depends="release, _buildmagic:release:zip"/>

  <target name="release-tar"
    description="Builds a TAR distribution."
    depends="release, _buildmagic:release:tar"/>

  <target name="release-tgz"
    description="Builds a TAR-GZ distribution."
    depends="release, _buildmagic:release:tgz"/>

  <target name="release-all"
    description="Builds a distribution for each archive type."
    depends="release-zip, release-tgz"/>


  <!-- ================================================================== -->
  <!-- Cleaning                                                           -->
  <!-- ================================================================== -->

  <!-- Clean up all build output -->
  <target name="clean"
    description="Cleans up most generated files."
    depends="_buildmagic:clean">
  </target>

  <!-- Clean up all generated files -->
  <target name="clobber"
    description="Cleans up all generated files."
    depends="_buildmagic:clobber, clean">
  </target>


  <!-- ================================================================== -->
  <!-- Misc.                                                              -->
  <!-- ================================================================== -->

  <target name="main"
    description="Executes the default target (most)."
    depends="most"/>

  <target name="all"
    description="Builds everything."
    depends="jars, docs"/>

  <target name="most"
    description="Builds almost everything."
    depends="jars"/>

  <target name="help"
    description="Show this help message."
    depends="_buildmagic:help:standard"/>

</project>
