FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Mobility
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
September 29, 2004

BlackBerry Development: Using Apache Ant

(Page 3 of 5)

The Ant Script for BlackBerry

Our Ant script was written following the Makefile in Listing 1. Our script provides build tasks to clean directories, and build our application. Our Ant script consist of the following major tasks:

  • Common build tasks for MIDP applications - this provides tasks such as clean, init, compile, preverify, prepare the JAD and MANIFEST files, and prepare the JAR file.
  • BlackBerry-specific build tasks - this provides task to generate the BlackBerry-specific files.

Separating the build into these steps allows us to easily create both a JAD/JAR and COD files. Note how the common build tasks generate a MANIFEST, JAD, and JAR files, and how the generated JAD and JAR files are used as input into the BlackBerry-specific build tasks.

Figure 4. Ant Script Build Tasks

Listing 3 shows the finished Ant script:

Listing 3. The Ant Script

<?xml version="1.0"?>

<project name="MyClientApp" default="build" basedir=".">

<property name="ver" value="1.0"/> <property name="codename" value="MyClientApp"/>

<property name="midp_lib" location="${j2mewtk.home}/lib/midpapi.zip"/>

<property name="build.jars" location="lib/thirdparty"/> <property name="bbjdebuild.jars" location="${build.jars}/jde3.7"/> <property name="net_rim_api.jar" value="${bbjdebuild.jars}/net_rim_api.jar"/>

<property name="src" location="src"/> <property name="resources" location="res"/> <property name="lib" location="lib"/>

<property name="unpreverified.classes" value="classes/unpreverified"/> <property name="obfuscated.classes" value="classes/obfuscated"/> <property name="final.classes" value="classes/final"/>

<property name="name" value="${codename}"/> <property name="jad.template" value="worktrack.jad.template"/> <property name="jadfile" value="output/tojar/${name}.jad"/> <property name="jarfile" value="output/tojar/${name}.jar"/>

<property name="manifest.template" value="manifest.template"/> <property name="manifestfile" value="MANIFEST.MF"/>

<property name="temp.jar" value="output/tojar/${name}_t.jar"/> <property name="obfuscated.jar" value="output/tojar/${name}_t_o.jar"/> <property name="preverified.jar" value="output/tojar/${name}_p.jar"/> <property name="final.jar" value="output/tojar/${name}.jar"/>

<property name="wtk.home" value="${j2mewtk.home}"/> <property name="antenna.jar" value="antenna-bin-0.9.12.jar"/> <taskdef name="wtkbuild" classname="de.pleumann.antenna.WtkBuild" classpath="${build.jars}/${antenna.jar}"/>

<taskdef name="wtkpreverify" classname="de.pleumann.antenna.WtkPreverify" classpath="${build.jars}/${antenna.jar}"/>

<taskdef name="wtkpackage" classname="de.pleumann.antenna.WtkPackage" classpath="${build.jars}/${antenna.jar}"/>

<target name="init" depends="clean"> <mkdir dir="classes"/> <mkdir dir="${unpreverified.classes}"/> <mkdir dir="${obfuscated.classes}"/> <mkdir dir="${final.classes}"/> <mkdir dir="output"/> <mkdir dir="output/tojar"/> <mkdir dir="output/tocod"/> </target>

<target name="clean"> <delete file="${name}.jad"/> <delete file="${name}.jar"/> <delete file="${codename}.cod"/> <delete file="${codename}.lst"/> <delete file="${codename}.debug"/> <delete file="${codename}.csl"/> <delete file="${codename}.cso"/> <delete dir="classes"/> <delete dir="output"/> </target>

Previous Page | 1 | 2 | 3 | 4 | 5 Next Page
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK