<?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">
   <!ENTITY targets SYSTEM "../tools/etc/buildmagic/targets.ent">
]>

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

<!-- $Id: build.xml 45757 2006-06-22 20:12:46Z rloehr $ -->

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

  <!-- ================================================================== -->
  <!-- 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;

  <!--
     | Include the normal targets.
   -->
  &targets;

  <!-- ================================================================== -->
  <!-- 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="system"/>
    <property name="module.Name" value="JBoss System"/>
    <property name="module.version" value="DEV"/>

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

    &libraries;

    <!-- The combined library classpath -->
    <path id="library.classpath">
      <path refid="junit.junit.classpath"/>
      <path refid="gnu.getopt.classpath"/>
      <path refid="apache.xerces.classpath"/>
      <path refid="apache.log4j.classpath"/>
      <path refid="apache.commons.classpath"/>
      <path refid="oswego.concurrent.classpath"/>
      <path refid="dom4j.dom4j.classpath"/>
      <path refid="jboss.jbossxb.classpath"/>
    </path>

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

    &modules;

    <!-- The combined dependant module classpath -->
    <path id="dependentmodule.classpath">
      <path refid="jboss.common.classpath"/>
      <path refid="jboss.jmx.classpath"/>
    </path>

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

    <property name="jar.prefix" value="jboss-system"/>
    <property name="jar.client.includes" 
              value="org/jboss/deployment/DeploymentException*,
                     org/jboss/deployment/IncompleteDeploymentException*,
                     org/jboss/deployment/Deployer*,
                     org/jboss/system/Registry.class,
                     org/jboss/system/Service.class,
                     org/jboss/system/server/ServerLoader*.class,
                     org/jboss/system/server/Server.class,
                     org/jboss/system/server/ServerConfig.class,
                     **/*MBean.class"
    />

    <call target="_default:task-init"/>

  </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"
	  description="Compile all source files."
	  depends="_default:compile-classes,
              _default:compile-resources,
              _default:compile-etc,
              _default:compile-bin"/>

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

  <target name="bypasslog4jboot" depends="init">

     <uptodate property="log4jboot-bypass.on" targetfile="${build.lib}/log4j-boot.jar">
        <srcfiles dir="${apache.log4j.lib}" includes="log4j.jar"/>
     </uptodate>

  </target>

  <target name="log4jboot" depends="bypasslog4jboot" unless="log4jboot-bypass.on">

    <!--
       | Build log4j-boot.jar This is a minimal subset of the log4j
       | classes that allow the boot process to use log4j but avoids
       | loading log4j classes that depend on other features like
       | JMS, JDBC, JavaMail, etc.
     -->
    <mkdir dir="${build.gen}/log4j"/>
    <unjar src="${apache.log4j.lib}/log4j.jar" dest="${build.gen}/log4j"/>
    <jar jarfile="${build.lib}/log4j-boot.jar">
      <fileset dir="${build.gen}/log4j">
        <include name="org/apache/log4j/*"/>
        <include name="org/apache/log4j/config/*"/>
        <include name="org/apache/log4j/helpers/*"/>
        <include name="org/apache/log4j/or/*"/>
        <include name="org/apache/log4j/spi/*"/>
      </fileset>
    </jar>

  </target>

  <target name="bypassgetopt" depends="init">

     <uptodate property="getopt-bypass.on" targetfile="${build.lib}/run.jar">
        <srcfiles dir="${gnu.getopt.lib}" includes="getopt.jar"/>
     </uptodate>

  </target>

  <target name="getopt" depends="bypassgetopt" unless="getopt-bypass.on">

    <!-- Unjar getopt better packaging (but slower builds) -->
    <mkdir dir="${build.gen}/getopt"/>
    <unjar src="${gnu.getopt.lib}/getopt.jar" dest="${build.gen}/getopt"/>

  </target>

  <!-- 
     |  Build all jar files.
    -->
  <target name="module-jars" depends="log4jboot, getopt">

    <!-- Server and client jars -->
    <call target="_default:server-client-jars"/>

    <!-- -->
    <jar jarfile="${build.lib}/jboss-system.jar" manifest="${build.etc}/default.mf">
      <fileset dir="${build.classes}" />
      <fileset dir="${build.resources}">
        <include name="dtd/**"/>
      </fileset>
    </jar>
    
    <!-- Build jboss-boot.jar -->
    <jar jarfile="${build.lib}/jboss-boot.jar" manifest="${build.etc}/default.mf">
      <fileset dir="${build.classes}">
        <include name="org/jboss/system/server/NoAnnotationURLClassLoader.class"/>
        <include name="org/jboss/system/server/ServerLoader*.class"/>
        <include name="org/jboss/system/server/Server.class"/>
        <include name="org/jboss/system/server/ServerConfig.class"/>
      </fileset>
    </jar>

    <!-- Build run.jar -->
    <jar jarfile="${build.lib}/run.jar" manifest="${build.etc}/run.mf">
      <fileset dir="${build.classes}">
        <include name="org/jboss/Version*.class"/>
        <include name="org/jboss/Main*.class"/>
        <include name="org/jboss/system/JBossRMIClassLoader.class"/>
        <include name="org/jboss/system/logging/*"/>
        <include name="org/jboss/system/server/NoAnnotationURLClassLoader.class"/>
        <include name="org/jboss/system/server/ServerLoader*.class"/>
        <include name="org/jboss/system/server/Server.class"/>
        <include name="org/jboss/system/server/ServerConfig.class"/>
        <include name="org/jboss/system/server/ServerConfigUtil.class"/>
        <include name="org/jboss/system/server/jmx/*"/>
        <include name="org/jboss/system/ORBSingleton.class"/>
      </fileset>
      <fileset dir="${build.resources}">
         <include name="log4j*.properties"/>
         <include name="jdklogger.properties"/>
        <include name="org/jboss/version.properties"/>
      </fileset>

      <!-- Include getopt -->
      <fileset dir="${build.gen}/getopt">
        <include name="**"/>
      </fileset>
    </jar>

    <!--
       | JBoss/Testsuite Support
     -->

    <!-- testsuite-support.jar -->
    <jar jarfile="${build.lib}/testsuite-support.jar" manifest="${build.etc}/default.mf">
      <fileset dir="${build.classes}">
         <include name="org/jboss/deployment/**"/>
         <include name="org/jboss/system/Service.class"/>
         <include name="org/jboss/system/ServiceMBean.class"/>
         <include name="org/jboss/system/*MBeanSupport.class"/>
         <include name="org/jboss/system/MBeanClassLoader*.class"/>
         <include name="org/jboss/system/UnifiedClassLoader*.class"/>
         <include name="org/jboss/system/ServiceLibraries*.class"/>
         <include name="org/jboss/system/server/*MBean.class"/>
         <include name="org/jboss/system/server/ServerConfigLocator.class"/>
         <include name="org/jboss/system/server/ServerConfig.class"/>
         <include name="org/jboss/system/server/Server.class"/>
      </fileset>
    </jar>

  </target>

</project>
