<!--
  JBoss, Home of Professional Open Source
  Copyright 2006, Red Hat Middleware LLC, and individual contributors
  as indicated by the @author tags.
  See the copyright.txt in the distribution for a full listing
  of individual contributors.
  This copyrighted material is made available to anyone wishing to use,
  modify, copy, or redistribute it subject to the terms and conditions
  of the GNU Lesser General Public License, v. 2.1.
  This program is distributed in the hope that it will be useful, but WITHOUT A
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License,
  v.2.1 along with this distribution; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  MA  02110-1301, USA.


  (C) 2005-2006,
  @author JBoss Inc.
-->
<!--
    Copyright (C) 2003, 2004
    Arjuna Technologies Limited
    Newcastle upon Tyne, UK

    $Id: build.xml 2342 2006-03-30 13:06:17Z  $
-->

<!--
    This is the build script for the JBoss Transactions product trailmap
    it has the capability to build the trailmap. Consult the trailmap
    itself for more information <ats_install_root>/trailmap/html/index.html
-->
<project name="JBossTS_TrailMap" default="buildjar" basedir=".">

    <!-- Where the transaction has been installed to, this should not need changing by default -->
    <property name="jbosstshome" value=".."/>

    <!-- This source code directory for the trailmap -->
    <property name="src" value="src"/>

    <!-- Where the trailmap source code should be built to -->
    <property name="build" value="build"/>

    <!-- The directory where the trailmap JAR should be created under -->
    <property name="lib" value="lib"/>

    <!-- The location of JacORB to use. This should not need changing unless a different version of JacORB is used -->
    <property name="jacorb-home" value="${jbosstshome}/jacorb"/>

    <!-- The location of the Arjuna IDL files used by the JTS -->
    <property name="jbossts-include" value="${jbosstshome}/idl"/>

    <!-- The include files required by JacORB -->
    <property name="jacorb-include" value="${jacorb-home}/idl/omg"/>


    <!--
        This target is responsible for final assembly of the trailmap JAR file. It uses the compile dependency to
        ensure that the code has already been built.
    -->
    <target name="buildjar" depends="compile">
        <jar basedir="${build}" jarfile="${lib}/jbossts-demo.jar"/>
    </target>


    <!--
        The compile target is responsible for compiling the source code into the build directory. Before compilation
        can take place the target requires a dependency target idl to have completed.
    -->
    <target name="compile" depends="idl">
        <javac srcdir="${src}" destdir="${build}">
            <classpath>
                <fileset dir="${jbosstshome}/lib" includes="*.jar"/>
                <fileset dir="${jbosstshome}/lib/ext" includes="*.jar,*.zip"/>
                <fileset dir="${jacorb-home}/lib" includes="*.jar"/>
            </classpath>
        </javac>
    </target>


    <!--
        The idl target is used to create the stub classes for the trailmap. It requires that the build directories
        already exist, hence the dependency on prepare.
    -->
    <target name="idl" depends="prepare">

        <!-- Create the stub classes for the installation verification step of the trailmap -->
        <java classname="org.jacorb.idl.parser" fork="yes">
            <classpath>
                <fileset dir="${jacorb-home}/lib" includes="*.jar"/>
            </classpath>
            <arg value="-I${jbossts-include}"/>
            <arg value="-I${jacorb-include}"/>
            <arg line="-d ${src}/generated"/>
            <arg value="${src}/com/arjuna/demo/simple/Hello.idl"/>
        </java>

        <!-- Create the stub classes for the implicit propogation Bank sample -->
        <java classname="org.jacorb.idl.parser" fork="yes">
            <classpath>
                <fileset dir="${jacorb-home}/lib" includes="*.jar"/>
            </classpath>
            <arg value="-I${jbossts-include}"/>
            <arg value="-I${jacorb-include}"/>
            <arg line="-d ${src}/generated"/>
            <arg value="${src}/com/arjuna/demo/jts/remotebank/Bank.idl"/>
        </java>

        <!-- Create the stub classes for the explicit propogation Bank sample -->
        <java classname="org.jacorb.idl.parser" fork="yes">
            <classpath>
                <fileset dir="${jacorb-home}/lib" includes="*.jar"/>
            </classpath>
            <arg value="-I${jbossts-include}"/>
            <arg value="-I${jacorb-include}"/>
            <arg line="-d ${src}/generated"/>
            <arg value="${src}/com/arjuna/demo/jts/explicitremotebank/Bank.idl"/>
        </java>

        <!-- Create the stub classes for the JBoss Transactional-Objects for Java extension Bank sample -->
        <java classname="org.jacorb.idl.parser" fork="yes">
            <classpath>
                <fileset dir="${jacorb-home}/lib" includes="*.jar"/>
            </classpath>
            <arg value="-I${jbossts-include}"/>
            <arg value="-I${jacorb-include}"/>
            <arg line="-d ${src}/generated"/>
            <arg value="${src}/com/arjuna/demo/jts/txojbank/Bank.idl"/>
        </java>
    </target>


    <!--
        Prepare is the base target for building the trailmap. It is responsible for ensuring that the
        directories required by the rest of the trailmap build system are present
    -->
    <target name="prepare">
        <mkdir dir="${build}"/>
        <mkdir dir="${lib}"/>
    </target>


    <!--
        This target is reponsible for cleaning the build directories. It may be invoked before buildjar to ensure
        that no old classes remain (if the user has changed the source code)
    -->
    <target name="clean" description="clean up">
        <delete dir="${build}"/>
        <delete dir="${lib}"/>
    </target>

</project>

