<property name="app.title" value="helloLWUIT" />
<property name="app.version" value="1" />
<property name="app.icon" value="/icon.png" />
<property name="app.vendor" value="foo" />
<target name="post-init">
<available file="${platform.home}/bin/rapc.exe" property="do.rapc" />
<condition property="jpda.port" value="8000">
<isset property="do.rapc">
</isset>
</condition>
</target>
<target name="post-jar" if="do.rapc">
<antcall target="bbbuild" />
</target>
<target name="post-clean">
<delete failonerror="false">
<fileset dir="${platform.home}/simulator">
<include name="**/${name}.*">
</include>
</fileset>
</delete>
</target>
<typedef resource="bb-ant-defs.xml" classpath="bb-ant-tools.jar" />
<target name="bbbuild" description="blackberry build" depends="init">
<echo message="rapc build, dir=${dist.dir}"></echo>
<mkdir dir="${dist.dir}/bbant" />
<rapc verbose="true" output="${name}" jdehome="${platform.home}" import="${platform.bootclasspath}" destdir="${dist.dir}/bbant/" noconvert="true">
<src>
<fileset file="${dist.dir}/${dist.jar}" />
</src>
<jdp title="${app.title}" vendor="${app.vendor}" version="${app.version}" type="cldc" icon="${app.icon}" >
</jdp>
</rapc>
<!-- sigtool jdehome="C:Program FilesResearch In MotionBlackBerry JDE 4.7.0" codfile="${dist.dir}/bbant/${name}.cod" password="" / -->
<alx destdir="${dist.dir}/bbant" filename="${name}.alx">
<application id="${app.title}">
<codset>
<fileset dir="${dist.dir}/bbant" includes="*.cod">
</fileset>
</codset>
</application>
</alx>
<mkdir dir="${dist.dir}/bbant-final" />
<jadtool input="${dist.dir}/bbant/${dist.jad}" destdir="${dist.dir}/bbant-final">
<fileset dir="${dist.dir}/bbant" includes="*.cod">
</fileset>
</jadtool>
</target>
<target name="copyBBSimulator" depends="bbbuild" if="do.rapc">
<copy todir="${platform.home}/simulator" verbose="true">
<fileset dir="${dist.dir}/bbant">
<include name="*.cod"/>
<include name="*.jad" />
</fileset>
</copy>
</target>
<target name="bb-run" depends="copyBBSimulator">
<exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows XP"
dir="${platform.home}/simulator"
executable="${platform.home}/simulator/${platform.device}.bat"
failonerror="true" resolveExecutable="true"/>
</target>
It has following improvements:
- Separate out the customized parameters in the build scriciptThen entire build script only needs following customized parameters: app.title, app.version, app.icon, app.vendor. You only need to configure them with your own application parameters.
- Simplify the build script. In the old build script, you have to use target "copyBBTouchSources" and "copyBBSources" to copy and update the LWUIT library source code into specific folder, then call rapc compiler to build the entire application. But when you investigate a little bit deeper, since NetBeans IDE already generate jar file for you, which already included the preprocessed application and the LWUIT blackbery library class files, why not just pass this jar file to rapc and then generate the cod file? based on this idea, I modified the target "bbbuild" and it works.
- One build script supports both BlackBerry touch and non-touch build. since the build script is simplified and only use jar file to generate cod file,the touch or non-touch specific files are already embedded in the jar file, the build script itself becomes generic. To tested it, I installed JDE 4.5 and JDE 4.7 two different JDE in the NetBeans, and set up 4.5 and 4.7 different configurations in my project, and I found both works.
- Added the ant target "bb-run", which allow you run the application in the blackberry simulator. To make it work, you had better to check the nbproject\project.properties file, if the simualtor device name is configured properly, In JDE 4.7, the device name is 9500, like this:
configs.BlackBerryTouch.platform.device=9500
In 4.5, the device name is 8320, like this:
configs.BlackBerry.platform.device=8320
Update: Sample project
Please click here to download the sample project.
Please click here to download the sample project.