Home

 

Creating the build script

To build the RAD75EJBEAR enterprise application, we created an Ant build script (build.xml) that utilizes the Java EE Ant tasks provided by RAD.

To add the Ant build script to the project, do these steps:

In the Enterprise Explorer view, expand RAD75EJBEAR, and select META-INF.

Select File | /b>Æ New Æ Other.

In the New File dialog, select General Æ File, and click Next.

Type build.xml in the File name field, and click Finish.

Double-click the build.xml file to open it in the editor. Copy and paste the text in c:\7672code\ant\j2ee\build.txt into the build.xml file.

Modify the value for the work.dir property to match your desired working directory (for example, c:/temp/RAD7AntEE), as highlighted in Example | 5-1.

Example 25-1 Java EE Ant build.xml script

<?xml version="1.0" encoding="UTF-8"?>
<project name="ITSO RAD Pro Guide Ant" default="Total" basedir=".">

	<!-- Set global properties -->
	<property name="work.dir" value="c:/temp/RAD75AntEE" />
	<property name="dist" value="${work.dir}/dist" />
	<property name="project.ear" value="RAD75EJBEAR" />
	<property name="project.ejb" value="RAD75EJB" />
	<property name="project.war" value="RAD75EJBTestWeb" />
	<property name="type" value="incremental" />
	<property name="debug" value="true" />
	<property name="source" value="true" />
	<property name="meta" value="false" />
	<property name="noValidate" value="false" />

The build.xml script includes the following Ant targets, which correspond to common Java EE application build:

deployEjb: This generates the deploy code for all EJBs in the project.

buildEjb: This builds the EJB project (compiles resources within the project).

buildWar: This builds the Web project (compiles resources within the project).

buildEar: This builds the Enterprise Application project (compiles resources within the project).

exportEjb: This exports the EJB project to a JAR file.

exportWar: This exports the Web project to a WAR file.

exportEar: This exports the Enterprise Application project to an EAR file.

buildAll: This invokes the buildEjb, buildWar, and buildEar targets.

exportAll: This invokes the exportEjb, exportWar, and exportEar targets to create the RAD7EJBEAR.ear used for deployment.

The additional targets are:

init: Initialize and create a directory.

info: Print out the properties.

Total: Invokes buildAll and exportAll.

clean: Delete the output files.
ibm.com/redbooks