<?xml version="1.0"?>

  <!DOCTYPE project [
       <!ENTITY properties SYSTEM 'file:./properties.xml'>
       <!ENTITY debug SYSTEM 'file:./debug.xml'>
       <!ENTITY classpaths SYSTEM 'file:./classpaths.xml'>
   ]>

<project default="dist" name="CincoSoft-InstantBank" basedir=".">

<description>
This build file constructs the full Instantbank project. It generates three
ear files correponding to the collections (instantbank.ear),
letters (lettertemplate.ear) and servicing (servicing.ear) modules of
the system.

Restrictions
============
Requires ant-1.5.1

Main targets:
=============
The default target is "dist"

- dist: Constructs all the system. Many subtasks are avoided if the final result
        is already present and up to date.
- clean: Deletes all the constructed jars, ears, wars. Must be used before "dist"
         if you want to construct the system "from scratch".
- clean_iblibs: Deletes jar files of instantbank own libraries.

- clean_collections: Deletes byproducts related to collections.
- build_collections: Rebuilds the collections module after deleting the related
        compiled classes and generated ear, war and ejb.jars.
        
- clean_letters: Deletes byproducts related to letters.
- build_letters: Rebuilds the letters module after deleting the related
        compiled classes and generated ear, war and ejb.jars.
        
- clean_servicing: Deletes byproducts related to servicing.
- build_servicing: Rebuilds the servicing module after deleting the related
        compiled classes and generated ear, war and ejb.jars.
        
#section_build_ear1()

- javadocs: generates the javadoc documentation of the system. This target
        is independent from dist.

</description>

   <!-- import external fragments -->
   &properties;
   &classpaths;

   <target name="debug">
     &debug;
   </target>


   <!-- ======================================================================== -->
   <!-- Public Targets                                                           -->
   <!-- ======================================================================== -->

   <target name="default" depends="dist" description="default: build everything"/>

   <target name="docs" depends="javadocs, xref" description="generate documentation"/>

   <target name="clean"
           depends="clean_collections,clean_letters,clean_servicing,clean_iblibs"
           description="Deletes all previous build artifacts">
      <delete failonerror="false">
        <fileset dir="${build.dir}"/>
      </delete>
      <delete failonerror="false">
        <fileset dir="${dist.dir}"/>
      </delete>
   </target>

   <target name="clean_collections"
           description="cleans collections ear,war and ejbs">
       <echo message="cleaning collections module"/>
       <delete failonerror="false">
          <fileset dir="${build.classes.dir}"/>
          <fileset dir="${collections.dist.dir}"/>
          <fileset dir="${dist.bin.dir}">
            <include name="instantbank.ear"/>
          </fileset>
       </delete>
   </target>

   <target name="clean_letters"
           description="cleans letters ear,war and ejbs">
       <echo message="cleaning letters module"/>
       <delete failonerror="false">
          <fileset dir="${build.classes.dir}"/>
          <fileset dir="${letters.dist.dir}"/>
          <fileset dir="${dist.bin.dir}">
            <include name="lettertemplate.ear"/>
          </fileset>
       </delete>
   </target>

   <target name="clean_servicing"
           description="cleans servicing ear,war and ejbs">
       <echo message="cleaning servicing module"/>
       <delete failonerror="false">
          <fileset dir="${build.classes.dir}"/>
          <fileset dir="${servicing.dist.dir}"/>
          <fileset dir="${dist.bin.dir}">
            <include name="servicing.ear"/>
          </fileset>
       </delete>
   </target>

   <!--      
   #section_build_ear2() 
   -->
   
   
   <target name="clean_edit" description="clean back-up sources after manual edition">
      <echo message="cleaning back-up sources after manual edition"/>
      <delete  failonerror="false">
         <fileset dir="${root.dir}" defaultexcludes="false">
            <include name="**/*~"/>
            <include name="**/.#*"/>
         </fileset>
      </delete>
   </target>

   <target name="clean_iblibs" description="clean instantbank constructed libraries">
      <echo message="cleaning instantbank constructed libraries"/>
      <delete  failonerror="false">
         <fileset dir="${instantbank-libs.dist.dir}"/>
      </delete>
   </target>
   
   <target name="clean_docs" description="clean instantbank documentation">
      <echo message="cleaning instantbank documentation"/>
      <delete  dir="${xref.dir}"/>
      <delete  dir="${javadoc.dir}"/>
   </target>

   <!-- ========================== -->
   <!-- The full generating target -->
   <!-- ========================== -->
   <target name="dist" depends="compile" description="create EARs">
      <echo level="info" message="Building all the system"/>

      <!-- packing instantbank own libraries -->
      <ant antfile="build_lib.xml" target="dist"/>

      <!-- Building ejb jars -->
      <ant antfile="build_ejb.xml" target="dist"/>


      <!-- =========================== -->
      <!-- Building war files          -->
      <!-- =========================== -->

      <ant antfile="build_instantbank_war.xml" target="dist">
         <property name='war.name' value='Instantbank'/>
         <property name='web.root' value='${web.dir}/instantbank'/>
      </ant>

      <ant antfile="build_lettertemplate_war.xml" target="dist">
         <property name='war.name' value='lettertemplate'/>
         <property name='web.root' value='${web.dir}/lettertemplate'/>
      </ant>

      <ant antfile="build_servicing_war.xml" target="dist">
         <property name='war.name' value='servicing'/>
         <property name='web.root' value='${web.dir}/servicing'/>
      </ant>
      
      <!--      
      #section_build_ear3() 
      -->
      

      <!-- =========================== -->
      <!-- Building ear modules        -->
      <!-- =========================== -->

      <ant antfile="build_ear.xml" target="dist">
         <property name="base.ear.dist.dir" location="${collections.dist.dir}"/>
         <property name="ear.name" value="instantbank"/>
         <property name="ear.src.dir" location="${web.dir}/instantbank"/>
      </ant>

      <ant antfile="build_ear.xml" target="dist">
         <property name="base.ear.dist.dir" location="${letters.dist.dir}"/>
         <property name="ear.name" value="lettertemplate"/>
         <property name="ear.src.dir" location="${web.dir}/lettertemplate"/>
      </ant>

      <ant antfile="build_ear.xml" target="dist">
         <property name="base.ear.dist.dir" location="${servicing.dist.dir}"/>
         <property name="ear.name" value="servicing"/>
         <property name="ear.src.dir" location="${web.dir}/servicing"/>
      </ant>
      
      <!--      
      #section_build_ear4() 
      -->
      
   </target>

   <!-- =================== -->
   <!-- building by modules -->
   <!-- =================== -->

      <target name="build_collections" depends="clean_collections,dist"
           description="builds only the collections module"/>

      <target name="build_letters" depends="clean_letters,dist"
           description="builds only the letters module"/>

      <target name="build_servicing" depends="clean_servicing,dist"
           description="builds only the servicing module"/>
           
      <!--      
      #section_build_ear5() 
      -->


   <!-- ======================================================================== -->
   <!-- Private Targets                                                          -->
   <!-- ======================================================================== -->

   <target name="compile" depends="init">
     <javac destdir="${build.classes.dir}"
            srcdir="${src.dir}">
       <bootclasspath refid="boot.classpath"/>     
       <classpath refid="compile.classpath"/>
       <include name="**/*.java"/>
     </javac>
   </target>

   <target name="javadocs" depends="compile">
     <ant antfile='build_javadoc.xml'/>
   </target>
   
   <target name="xref" depends="compile">
     <ant antfile='build_xref.xml'/>
   </target>

   <target name='pretty-printing' depends='init'>
     <pretty settingsDir='${pretty.conf.dir}' cvs='true'>
       <fileset dir='${src.dir}'>
          <include name='**/*.java'/>
       </fileset>
     </pretty>
   </target>


   <target name="init">
     <echo message="Building ${ant.project.name}"/>
     <tstamp/>

     <!-- create directories used for building -->

     <mkdir dir="${build.dir}"/>
     <mkdir dir="${build.classes.dir}"/>
     <mkdir dir="${dist.dir}"/>
     <mkdir dir="${dist.bin.dir}"/>
     <mkdir dir="${instantbank-libs.dist.dir}"/>

     <mkdir dir="${collections.dist.dir}"/>
     <mkdir dir="${letters.dist.dir}"/>
     <mkdir dir="${servicing.dist.dir}"/>
     
      <!--      
      #section_build_ear6() 
      -->

     <!-- defines the pretty printing task -->
     <taskdef name='pretty' classname='org.acm.seguin.ant.Pretty' classpath='${jrefactory.jar}'/>

   </target>

</project>