Tuesday, June 19, 2007

Ant|Build file example

Build.xml

<!--

      Ant script to prepare the build process

-->

<project name="WSG" default="no.target" basedir="." >

    <description>

        Prepares the build

    </description>

 

build_external.properties

 

#############################################################################

#                                                                           #

#  This file contains the properties for the Wholesale Gateway build script #

#  for external releases                                                    #

#                                                                           #

#                                                                           #

#############################################################################

 

 

##################################################

# The following settings relate to JDBC

##################################################

 

#

# Oracle JDBC Settings

#

wsg.jdbc.db.type= WSG Oracle

wsg.jdbc.password=

wsg.jdbc.driver= oracle.jdbc.driver.OracleDriver

wsg.jdbc.testtable.sql =ec_servers

wsg.jdbc.context= oracle

jdbc.data.tablespace =WSG_DATA

jdbc.index.tablespace =WSG_INDEX

 

jdbc.itrust.sqldir =temp/ec_wsg/other/database_schema/wsg/itrust/wsg

 

 

##################################################

# The following settings relate to build

##################################################

 

# Local WebLogic directory

weblogic.home= /bea/weblogic81

 

wsg.managed.server.name =wsgManagedServer

 

wsg.fml.dir= FMLFieldTables

ec.core.dir= ../EC_Core

compile.dir= build

wsg.dist.dir= dist

wsg.src.dir= Java Sources

wsg.lib.dir= lib

wsg.project.name =WSG_Processes

product.name =WholesaleGateway

 

 

dobuild.xml

<!--

Ant build script to build the /dist/WSG.jar file.

This jar file contains all the classes used in the Wholesale Gateway project

-->

<project name="WSG" default="production.package" basedir= ".">

    <description>

        Builds the wsg.jar file

    </description>

  <!-- set global properties for this build -->

  <property file= "build.properties"/>

 

  <target name= "init">

    <!-- Create the build directory structure used by compile -->

    <mkdir dir= "${compile.dir}"/>

  </target>

 

  <!-- classpath for Java libraries -->

  <path id= "path.classpath">

    <fileset dir= "${ec.core.dir}/lib">

      <include name= "**/*.jar"/>

    </fileset>

    <fileset dir= "${wsg.lib.dir}">

      <include name= "**/*.jar"/>

    </fileset>

    <fileset dir= "${weblogic.home}/server/lib" includes= "weblogic.jar"/>

  </path>

 

 

  <target name= "compile" depends= "init"

        description="compile the source " >

      <!-- Compile the java code from ${wsg.src.dir} into ${compile.dir} -->

      <javac destdir= "${compile.dir}" debug= "true" deprecation= "on">

        <classpath refid= "path.classpath"/>

        <src path= "${wsg.src.dir}"/>

        <include name= "**/*.java" />

      </javac>

  </target>

 

 

  <target name= "dist" depends= "compile"

        description="generate the distribution" >

    <!-- Create the distribution directory -->

    <mkdir dir= "${wsg.dist.dir}"/>

 

    <!-- Put everything in ${compile.dir} into the WSG.jar file -->

    <jar destfile= "${wsg.dist.dir}/WSG.jar">

      <fileset dir= "${compile.dir}">

        <include name= "com/**/*.class"/>

        <exclude name= "com/ncs/exchangeconnect/wsg/tuxedo/**/*.class"/>

      </fileset>

    </jar>

 

 

      <!--

            Create the FocusFML.jar

      -->

      <mkdir dir= "${wsg.dist.dir}/fml"/>

      <copy file= "${wsg.fml.dir}/focus.fml" tofile= "${wsg.dist.dir}/fml/FocusFML"/>

 

      <java classname= "weblogic.wtc.jatmi.mkfldclass32" fork="true">

         <arg value= "${wsg.dist.dir}/fml/FocusFML"/>

         <classpath refid= "path.classpath"/>

      </java>

 

      <move file= "FocusFML.java" todir= "${wsg.dist.dir}/fml"/>

 

      <javac destdir= "${wsg.dist.dir}/fml" debug= "${javac.debug}" deprecation="on">

            <classpath refid= "path.classpath"/>

            <src path= "${wsg.dist.dir}/fml"/>

            <include name= "**/*.java" />

      </javac>

 

      <delete>

            <fileset dir= "${wsg.dist.dir}/fml">

                  <include name= "*.java"/>

                  <include name= "FocusFML"/>

            </fileset>

      </delete>

      <jar jarfile= "${wsg.dist.dir}/FocusFML.jar" basedir= "${wsg.dist.dir}/fml"/>

      <delete>

            <fileset dir= "${wsg.dist.dir}/fml">

                  <include name= "*.class"/>

            </fileset>

      </delete>

 

      <!--

            Create the IBSFML.jar

      -->

      <copy file= "${wsg.fml.dir}/ibs.fml" tofile= "${wsg.dist.dir}/fml/IBSFML"/>

 

      <java classname= "weblogic.wtc.jatmi.mkfldclass32" fork="true">

         <arg value= "${wsg.dist.dir}/fml/IBSFML"/>

         <classpath refid= "path.classpath"/>

      </java>

 

      <move file= "IBSFML.java" todir= "${wsg.dist.dir}/fml"/>

 

      <javac destdir= "${wsg.dist.dir}/fml" debug= "${javac.debug}" deprecation="on">

            <classpath refid= "path.classpath"/>

            <src path= "${wsg.dist.dir}/fml"/>

            <include name= "**/*.java" />

      </javac>

 

      <delete>

            <fileset dir= "${wsg.dist.dir}/fml">

                  <include name= "*.java"/>

                  <include name= "IBSFML"/>

            </fileset>

      </delete>

      <jar jarfile= "${wsg.dist.dir}/IBSFML.jar" basedir= "${wsg.dist.dir}/fml"/>

 

      <delete dir= "${wsg.dist.dir}/fml"/>

 

 

    <jar destfile= "${wsg.dist.dir}/wsg_dataenrich_receiver_sync.jar">

      <fileset dir= "${compile.dir}">

        <include name= "com/ncs/exchangeconnect/wsg/tuxedo/dataenrich/*.class"/>

      </fileset>

      <fileset dir= "${wsg.src.dir}/com/ncs/exchangeconnect/wsg/tuxedo/dataenrich">

        <include name= "META-INF/*.xml"/>

      </fileset>

    </jar>

 

    <jar destfile= "${wsg.dist.dir}/wsg_staupd_receiver_sync.jar">

      <fileset dir= "${compile.dir}">

        <include name= "com/ncs/exchangeconnect/wsg/tuxedo/staupd/*.class"/>

      </fileset>

      <fileset dir= "${wsg.src.dir}/com/ncs/exchangeconnect/wsg/tuxedo/staupd">

        <include name= "META-INF/*.xml"/>

      </fileset>

    </jar>

 

    <jar destfile= "${wsg.dist.dir}/wsg_prtnotify_receiver_sync.jar">

      <fileset dir= "${compile.dir}">

        <include name= "com/ncs/exchangeconnect/wsg/tuxedo/prtnotify/*.class"/>

      </fileset>

      <fileset dir= "${wsg.src.dir}/com/ncs/exchangeconnect/wsg/tuxedo/prtnotify">

        <include name= "META-INF/*.xml"/>

      </fileset>

    </jar>

 

      <!-- Clean up -->

      <delete dir= "${compile.dir}"/>

  </target>

 

  <target name= "repackage.ear" depends= "dist"

        description="repackage the EAR file for distribution" >

    <mkdir dir= "${wsg.dist.dir}/repack"/>

    <unzip src= "${ec.core.dir}/ec.ear" dest= "${wsg.dist.dir}/repack"/>

 

    <copy file= "${wsg.dist.dir}/WSG.jar" todir= "${wsg.dist.dir}/repack/APP-INF/lib" />

 

      <copy todir= "${wsg.dist.dir}/repack/APP-INF/lib">

            <fileset dir= "${wsg.lib.dir}">

                  <include name= "**/*.jar"/>

            </fileset>

      </copy>

 

    <move file= "${wsg.dist.dir}/wsg_dataenrich_receiver_sync.jar" todir="${wsg.dist.dir}/repack/"/>

    <move file= "${wsg.dist.dir}/wsg_staupd_receiver_sync.jar" todir="${wsg.dist.dir}/repack/"/>

    <move file= "${wsg.dist.dir}/wsg_prtnotify_receiver_sync.jar" todir="${wsg.dist.dir}/repack/"/>

 

      <copy file= "JSP/WEB-INF/classes/messages-acm.properties" tofile="JSP/WEB-INF/classes/messages-acm.properties.bak" />

      <replace file= "JSP/WEB-INF/classes/messages-acm.properties" token="@@@product.name@@@" value="${product.name }"/>

 

      <!-- Copy JSPs into a Temp directory. This is required so our JSPs have a new timestamp and get included in the war -->

    <mkdir dir= "${wsg.dist.dir}/tempJSP"/>

      <copy todir= "${wsg.dist.dir}/tempJSP">

            <fileset dir= "JSP">

                  <include name= "**/*.*"/>

                  <exclude name= "**/*.bak"/>

            </fileset>

      </copy>

 

      <war destfile= "${wsg.dist.dir}/repack/ec.war" update="true" webxml="JSP/WEB-INF/web.xml">

            <fileset dir= "${wsg.dist.dir}/tempJSP">

                  <include name= "**/*.*"/>

      </fileset>

    </war>

    <delete dir= "${wsg.dist.dir}/tempJSP"/>

 

 

    <move file= "JSP/WEB-INF/classes/messages-acm.properties.bak" tofile="JSP/WEB-INF/classes/messages-acm.properties" />

 

    <ear destfile= "${wsg.dist.dir}/ec_wsg.ear" appxml= "META-INF/application.xml">

      <fileset dir= "${wsg.dist.dir}/repack">

        <include name= "ec.war"/>

        <include name= "*.jar"/>

        <include name= "APP-INF/**/*.*"/>

        <exclude name= "*.ear"/>

      </fileset>

    </ear>

 

      <!-- Clean up -->

      <delete dir= "${wsg.dist.dir}/repack"/>

  </target>

 

 

  <target name= "repackage.filesystem" depends= "repackage.ear"

          description="creates the file system structure" >

    <mkdir dir= "${wsg.dist.dir}/temp/ec_wsg"/>

 

      <!-- Copy the core files across -->

      <copy todir= "${wsg.dist.dir}/temp/ec_wsg" includeEmptyDirs= "false" overwrite="true">

            <fileset dir= "${ec.core.dir}">

                  <exclude name= "**/*.ear"/>

                  <exclude name= "EC_domain/**/*.*"/>

            </fileset>

      </copy>

 

      <!-- Copy the core EC_domain to WSG_domain -->

      <copy todir= "${wsg.dist.dir}/temp/ec_wsg/WSG_domain" includeEmptyDirs="false" overwrite="true" >

            <fileset dir= "${ec.core.dir}/EC_domain">

                  <exclude name= "myserver/**/*.*"/>

            </fileset>

      </copy>

 

      <!-- Copy the WSG files -->

      <copy todir= "${wsg.dist.dir}/temp/ec_wsg" includeEmptyDirs= "false" overwrite="true">

            <fileset dir= "ECFiles/ec_wsg"/>

      </copy>

 

      <!-- Copy the WSG tables -->

      <copy todir= "${wsg.dist.dir}/temp/ec_wsg/other/database_schema/wsg" includeEmptyDirs="false" overwrite="true" >

            <fileset dir= "sql">

                  <include name= "**/*.sql"/>

            </fileset>

      </copy>

 

      <!-- Move the WSG.ear file -->

      <move file= "${wsg.dist.dir}/ec_wsg.ear" todir= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/applications" />

 

  </target>

 

 

  <!-- Use the development config.xml. This config deploys the product in a standalone WebLogic domain-->

   <target name= "development.configuration" depends= "repackage.filesystem"

          description="Use the config_dev.xml" >

 

      <property name= "weblogic.productionmode" value= "false"/>

 

      <copy file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config_dev.xml" tofile="${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config.xml" overwrite="true" />

      <copy file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic_dev.cmd" tofile="${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic.cmd" overwrite="true" />

 

      <delete file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config_prod.xml"/>

      <delete file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config_dev.xml"/>

 

      <delete file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic_prod.cmd"/>

      <delete file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic_dev.cmd"/>

 

      <antcall target= "substitute.variables"/>

  </target>

 

  <!-- Use the production config.xml. This config deploys the product in a managed WebLogic domain-->

  <target name= "production.configuration" depends= "repackage.filesystem"

          description="Use the config_prod.xml" >

 

      <property name= "weblogic.productionmode" value= "true"/>

 

      <copy file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config_prod.xml" tofile="${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config.xml" overwrite="true" />

      <copy file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic_prod.cmd" tofile="${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic.cmd" overwrite="true" />

 

      <delete file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config_prod.xml"/>

      <delete file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config_dev.xml"/>

 

      <delete file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic_prod.cmd"/>

      <delete file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic_dev.cmd"/>

 

      <antcall target= "substitute.variables"/>

  </target>

 

 

  <!-- Set all the environment variables -->

  <target name= "substitute.variables"

          description="Set all the environment variables" >

      <!-- Set the environmental settings -->

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config.xml" token="@@@wsg.jdbc.db.type@@@" value="${wsg.jdbc.db.type}" />

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config.xml" token="@@@wsg.jdbc.password@@@" value="${wsg.jdbc.password}" />

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config.xml" token="@@@wsg.jdbc.driver@@@" value="${wsg.jdbc.driver}" />

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config.xml" token="@@@wsg.jdbc.testtable.sql@@@" value="${wsg.jdbc.testtable.sql}" />

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config.xml" token="@@@weblogic.productionmode@@@" value="${weblogic.productionmode}" />

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/config.xml" token="@@@wsg.managed.server.name@@@" value="${ wsg.managed.server.name}"/>

 

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/etc/standard.conf" token="@@@wsg.project.name@@@" value="${ wsg.project.name}"/>

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/etc/wsgCustom.properties" token="@@@wsg.jdbc.context@@@" value="${wsg.jdbc.context}" />

 

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic.cmd" token="@@@weblogic.productionmode@@@" value="${weblogic.productionmode}" />

 

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/WSG_Domain/startWebLogic.sh" token="@@@weblogic.productionmode@@@" value="${weblogic.productionmode}" />

 

      <!-- Copy the WSG create script -->

      <copy file ="SQL/create-oracle.sql" todir= "${wsg.dist.dir}/temp/ec_wsg/other/database_schema" includeEmptyDirs="false" overwrite="true" />

 

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/other/database_schema/create-oracle.sql" token="@@@jdbc.data.tablespace@@@" value="${jdbc.data.tablespace}" />

      <replace file= "${wsg.dist.dir}/temp/ec_wsg/other/database_schema/create-oracle.sql" token="@@@jdbc.index.tablespace@@@" value="${jdbc.index.tablespace}" />

 

      <!-- Copy the iTrust tables -->

      <copy todir= "${wsg.dist.dir}/temp/ec_wsg/other/database_schema/itrust" includeEmptyDirs="false" overwrite="true" >

            <fileset dir= "${wsg.dist.dir}/${jdbc.itrust.sqldir}">

                  <include name= "**/*.sql"/>

            </fileset>

      </copy>

      <delete dir= "${wsg.dist.dir}/temp/ec_wsg/other/database_schema/wsg/itrust"/>

 

      <mkdir dir= "${wsg.dist.dir}/temp/domain/WSG_domain"/>

      <move todir= "${wsg.dist.dir}/temp/domain/WSG_domain" includeEmptyDirs="false" overwrite="true" >

            <fileset dir= "${wsg.dist.dir}/temp/ec_wsg/WSG_domain">

                  <include name= "**/*.*"/>

            </fileset>

      </move>

 

      <mkdir dir= "${wsg.dist.dir}/zip"/>

 

      <zip destfile= "${wsg.dist.dir}/zip/WSG_Files.zip"

             basedir="${wsg.dist.dir}/temp/ec_wsg"   />

      <zip destfile= "${wsg.dist.dir}/zip/WSG_Domain.zip"

             basedir="${wsg.dist.dir}/temp/domain"   />

 

      <copy todir= "${wsg.dist.dir}/zip" includeEmptyDirs= "false" overwrite="true">

            <fileset dir= "environments">

                  <include name= "**/*.*"/>

                  <exclude name= "internal/**/*.*"/>

            </fileset>

      </copy>

 

      <zip destfile= "${wsg.dist.dir}/WSG_Application.zip"

             basedir="${wsg.dist.dir}/zip"   />

 

 

      <zip destfile= "${wsg.dist.dir}/WSG_DatabaseSchema.zip"

             basedir="${wsg.dist.dir}/temp/ec_wsg/other/" includes= "**/*.sql" />

 

      <copy file= "../EC_Designer/ExchangeConnect Designer.zip" tofile= "${wsg.dist.dir}/ExchangeConnect Designer.zip" overwrite="true"/>

      <copy file= "ExportedWorkFlows/WSG_Processes.xml" tofile="${wsg.dist.dir}/WSG_Processes.xml" overwrite="true" />

 

 

      <!-- Clean up -->

      <delete dir= "${wsg.dist.dir}/temp"/>

      <delete dir= "${wsg.dist.dir}/zip"/>

 

  </target>

 

 

 

 

  <!-- Deploys the package on the local filesystem. This is for development only!! -->

  <target name= "deploy" depends= "development.configuration"

          description="Unzips the package ready for use" >

 

      <delete dir= "${wsg.deploy.dir}"/>

      <unzip src= "${wsg.dist.dir}/WSG_Application.zip" dest="${wsg.dist.dir}/temp"/>

      <copy file= "environments/internal/deploy_local.properties" tofile="${wsg.dist.dir}/temp/deploy.properties" overwrite="true" />

      <ant antfile= "build.xml" dir= "${wsg.dist.dir}/temp" target= "extract.admin"/>

      <delete dir= "${wsg.dist.dir}/temp"/>

  </target>

 

  <!-- Packages the product ready for production -->

  <target name= "production.package" depends= "production.configuration"

          description="Packages the product ready for production" >

  </target>

 

</project>

 

      <property name= "include.batch" value= "false"/>

 

  <target name= "no.target">

      <echo level= "info">

            Invalid usage:

            - use "ant local"..........to build and extract to a local PC

            - use "ant internal.st"....to build for the internal system test environment

            - use "ant internal.dev"...to build for the internal development environment

            - use "ant external".......to build for an external release

      </echo>

 

      <fail/>

  </target>

 

  <target name= "checkProps">

      <condition property= "include.batch.isTrue">

            <istrue value= "${include.batch}"/>

      </condition>

  </target>

 

  <target name= "integrate.batch" depends= "checkProps" if="include.batch.isTrue">

        <property name= "build.file" value= "dobuild_includebatch.xml"/>

 

            <echo level= "info">

                  Integrating the Batch Job functionality

            </echo>

 

  </target>

 

  <target name= "no.batch" depends= "checkProps" unless= "include.batch.isTrue">

        <property name= "build.file" value= "dobuild.xml"/>

 

            <echo level= "info">

                  NOT Integrating the Batch Job functionality

            </echo>

  </target>

 

  <target name= "init" depends= "integrate.batch, no.batch">

  </target>

 

  <target name= "local" depends= "init" description= "builds and deploys the project to a local PC" >

 

      <copy file= "build_local.properties" tofile= "build.properties" overwrite="true"/>

 

      <ant antfile= "${build.file}" target= "deploy"/>

 

      <delete file= "build.properties"/>

  </target>

 

 

  <target name= "internal.st" depends="init" description="builds ready for the internal SIT environment" >

 

      <copy file= "buildSIT_internal.properties" tofile= "build.properties" overwrite="true"/>

 

      <ant antfile= "${build.file}" target= "production.package"/>

 

      <delete file= "build.properties"/>

  </target>

 

 

  <target name= "internal.dev" depends= "init" description= "builds ready for the internal Development environment" >

 

      <copy file= "buildDev_internal.properties" tofile= "build.properties" overwrite="true"/>

 

      <ant antfile= "${build.file}" target= "production.package"/>

 

      <delete file= "build.properties"/>

  </target>

 

 

  <target name= "external" depends= "init" description= "builds ready for an external release" >

 

      <copy file= "build_external.properties" tofile= "build.properties" overwrite="true"/>

 

      <ant antfile= "${build.file}" target= "production.package"/>

 

      <delete file= "build.properties"/>

  </target>

 

        <target name= "WSGJar" description= "builds only WSG.jar file" >

 

            <echo level= "info">

                  *********************************

                  Note: Project Mary Batch Job

                        functionality is not included

                  *********************************

            </echo>

            <copy file= "build_external.properties" tofile= "build.properties" overwrite="true"/>

 

            <ant antfile= "utilsBuild.xml" target= "dist"/>

 

            <delete file= "build.properties"/>

        </target>

 

</project>

 

No comments: