Of these four Ant tasks, three are intended to simplify building J2ME code. Two (Preverify and UpdateJAD) are general purpose J2ME tasks. Preverify requires that the J2ME Wireless Toolkit be installed. The third (MakePRC) is for use with Sun's MIDP for PalmOS tools. If you are using either of those two tasks, you will need to download the tools from Sun, install them, and let Ant know where to find them as shown in the examples.
The last (JARSourceCopier) is intended to help gather just the source files that are relevant to a program or library release. It will track down and copy just the source files that correspond to class files in a JAR file. It's useful because it lets you easily select just the subset of source files that are needed for a particular distribution.
For all four tasks, you'll need to put
ant/lib directory and use a
element to let Ant know about the task. The examples below show how to do that.
If you encounter problems or have suggestions or would like to contribute your changes, please email me at email@example.com.
Preverify - Preverify files using J2ME Wireless Toolkit
UpdateJAD - Update the JAR file size in a JAD file
MakePRC - Convert class files into a PRC for use on PalmOS with MIDP4Palm support
JARSourceCopier - Copy .java files that correspond to .class files in a specified JAR file
Preverifies a set of class files to prepare them to run on a J2ME device on the KVM. Recursively searches unverified directory for class files and verfies them all. This task currently works with the J2ME Wireless toolkit for Windows and Linux.
|unverified||Directory which is the root of the unverified package hierarchy.||Yes|
|verified||Directory which is the root of the verified package hierarchy.||Yes|
<taskdef name="preverify" classname="com.stampysoft.ant.j2me.PreverifyTask" /> <property name="j2mewtk.home" value="c:/j2mewtk" /> <preverify unverified="./unverified" verified="./verified" />
Preverifies all the class files in
./unverified and puts the new class files in
Updates the MIDlet-Jar-Size entry in a JAD file with the new JAR file size.
Location of the JAD file
If the MIDlet-Jar-URL entry in the JAD starts with file://, whether or
not to interpret the path as relative to the location of the JAD
<taskdef name="updatejad" classname="com.stampysoft.ant.j2me.UpdateJARSizeTask" /> <updatejad jad="sample.jad" />
Examines the JAD file
sample.jad, checks the size of the JAR file
specified by the MIDlet-Jar-URL property, and updates the MIDlet-Jar-Size property
in the JAD if it is out of date.
If the MIDlet-JAR-URL property starts with "file://" the path is treated as an absolute path. Otherwise, the path should be relative to the location of the JAR file.
Turns a JAR (possibly accompanied by a JAD) into a PRC that can be transfered to a Palm handheld and executed. Mostly a thin wrapper around the MIDP4Palm utility, MakeMIDPApp.jar. Note that newer versions of MIDP4Palm have changed the location of this utility to ./Converter/Converter.jar. As of version 1.0.1, this task looks in both places.
This task currently supports both the full 1.0 release and the 1.0 Early Access release, although support for 1.0EA may be removed from future releases. It will automatically determine which is installed on your system and act accordingly. The updated version requires that the JAR file contain MIDP-related manifest information. There are many places to find information on what this manifest must include, but I've had success based on this JBuilder page.
Please note that the converter utility in the 1.0 release does not currently work with manifest files
generated by the Ant
<jar> task. Instead, use something like the following to first
build the JAR file and then add the manifest file in a separate step:
<jar jarfile="password.jar" basedir="../verified" includes="**/*.class" />
<arg line="ufm" />
<arg line="password.jar" />
<arg line="manifest-additions.mf" />
Please note that the author has not fully tested all possible usage. Most descriptions are taken from the help output from MakeMIDPApp.jar. Some options are not supported, like -resource and -empty.
|jar||JAR file containing the classes for the MIDlet.||Yes|
|mainclass||Fully qualified classname of the MIDlet that serves as the entry point to the application. Removed in MIDP4Palm 1.0.||One of the two|
|jad||JAD describing the MIDlet suite|
|verbose||Verbose output (true/false)||No|
|prc||Filename for resulting PRC, defaults to same filename as the jar attribute||No|
|version||Version tag for the MIDlet||No|
|name||Short name of application, seen in the launcher||No|
|longName||Long name for the application, seen in beaming, etc||No|
|creator||Creator ID for the application (Palm Creator ID)||No|
|type||File type for the application, defaults to appl||No|
|classpath||Where to search for application classes, should not be needed if everything is already in the JAR||No|
|bootclasspath||Where to search for system classes||No|
|icon||File containing icon for application
Must be in bmp, pbm, or bin (Palm Resource) format
|smallicon||Unknown - may be same as icon||No|
|beam||Whether or not the MIDlet supports beaming over IR (true/false). Removed in MIDP4Palm 1.0.||No|
|networking||Whether or not the application can perform networking (true/false, defaults to "false"). Removed in MIDP4Palm 1.0.||No|
|listicon||File containing the "list" icon for application. Removed in MIDP4Palm 1.0.||No|
<taskdef name="makePRC" classname="com.stampysoft.ant.j2me.JARToPRCTask" /> <property name="midp4palm.home" value="c:/midp4palm" /> <makePRC jar="sample.jar" jad="sample.jad" name="Sample MIDlet suite" />
sample.prc using the information in
and the classes from
sample.jar, using the entry point specified
in the JAD file.
<taskdef name="makePRC" classname="com.stampysoft.ant.j2me.JARToPRCTask" /> <property name="midp4palm.home" value="c:/midp4palm" /> <makePRC jar="sample.jar" mainclass="sample.MainClass" networking="true" />
sample.prc, enabling networking support, using the classes
sample.MainClass as the application
Copies a set of
.java files that correspond to
files in a JAR file.
|jar||JAR file which contains the .class files whose source should be copied.||Yes|
|src||Directory which is the root of the source code package hierarchy.||Yes|
|dest||Directory which is the root of the package hierarchy into which the .java files should be copied.||Yes|
<taskdef name="JARSourceCopier" classname="com.stampysoft.ant.misc.JARSourceCopierTask" /> <JARSourceCopier jar="./distribution.jar" src="./src" dest="./srcDistribution" />
./distribution.jar, looks for corresponding
./src, and copies the ones it finds into
Copyright © 2001 Josh Eckels. All rights reserved.