Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

BlackBerry Development: Using Apache Ant


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>


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.