Home

 

Creating the build file (BUbuild.xml)

To create the build file, we copy the build file from the headless Ant example and modify it for the RAD75EJBWebEAR enterprise application.

Copy the RAD75EJBEAR\META-INF\build.xml file to C:\sources\BUbuild.xml.

Modify the BUBuild.xml as highlighted in... The changes to the original build.xml file are:

Project names are different
Import the projects into the workspace before the build
Full build instead of incremental build

Example 25-3 BUbuild.xml for the build utility"

<?xml version="1.0" encoding="UTF-8"?>
<project name="ITSO RAD Pro Guide Ant Build Utility" default="Total"
																		basedir=".">
	<!-- Set global properties -->
	<property name="work.dir" value="c:/temp/RAD75BU" />
	<property name="dist" value="${work.dir}/dist" />
	<property name="project.ear" value="RAD75EJBWebEAR" />
	<property name="project.ejb" value="RAD75EJB" />
	<property name="project.war" value="RAD75EJBWeb" />
	<property name="project.jpa" value="RAD75JPA" />
	<property name="type" value="full" />
	<property name="debug" value="true" />
	<property name="source" value="true" />
	<property name="meta" value="false" />
	<property name="noValidate" value="false" />
	<target name="init">...
	<target name="info">
		<!-- Displays the properties for this run -->
		<echo message="debug=${debug}" />
		<echo message="type=${type}" />
		<echo message="source=${source}" />
		<echo message="meta=${meta}" />
		<echo message="noValidate=${noValidate}" />
		<echo message="Output directory=${dist}" />
		<echo message="project.ear=${project.ear}" />
		<echo message="project.ejb=${project.ejb}" />
		<echo message="project.war=${project.war}" />
		<echo message="project.jpa=${project.jpa}" />
	</target>
	
	<target name="importJPA">
		<projectImport projectname="${project.jpa}" />
		<eclipse.refreshLocal resource="${project.jpa}" />
	</target>
	<target name="importEJB">
		<projectImport projectname="${project.ejb}"  />
		<eclipse.refreshLocal resource="${project.ejb}" />
	</target>
	<target name="importWAR">
		<projectImport projectname="${project.war}"  />
		<eclipse.refreshLocal resource="${project.war}" />
	</target>
	<target name="importEAR">
		<projectImport projectname="${project.ear}" />
		<eclipse.refreshLocal resource="${project.ear}" />
	</target>
	<target name="importAll"
				depends="importJPA,importEJB,importWAR,importEAR">
		<!-- Import all projects and exports all files -->
		<echo message="Import All projects" />
	</target>
	
	<target name="deployEjb">...
	<target name="buildEjb" depends="deployEjb">...
	<target name="buildJPA">
		<!-- Builds the JPA project -->
		<projectBuild ProjectName="${project.jpa}" BuildType="${type}"
			DebugCompilation="${debug}" />
	</target>	
	<target name="buildWar">...
	<target name="buildEar">...
	<target name="exportEjb" depends="init">...
	<target name="exportWar" depends="init">...	
	<target name="exportEar" depends="init">...
	<target name="buildAll" depends="buildJPA,buildEjb,buildWar,buildEar">
		<!-- Builds all projects -->
		<echo message="Built all projects" />
	</target>
	<target name="exportAll" depends="exportEjb,exportWar,exportEar">...
	<target name="Total" depends="importAll,buildAll,exportAll">...
	<target name="clean">...
</project>

The projects are imported into the Eclipse workspace from the workspace directory itself, using targets such as:

<target name="importEJB">

<projectImport projectname="${project.ejb}"/>

<eclipse.refreshLocal resource="${project.ejb}" />

</target>

Because we do not specify the attribute projectLocation for the projectImport task, it is assumed that the projects to import are in the workspace directory. Note that projectImport does not make a physical copy of the projects, it just imports a reference to the projects.
ibm.com/redbooks