For Linux users/developers/fanboys, BlackBerry development is not a so Windows native thing cause almost all the programs from RIM are based on Java, which is the portable/platform independent thing. Just with a half day of digging, I found the way to build LogicMail under linux, with a native JDK 1.6 for Linux and Wireless Tool Kit from SUN. Of course you need something from RIM cause we are coding for his devices.
Let's get on the way now :)
Prepare
Of course, when you read this title you know what you want to get from this piece of text. I assume that you want to be a console freak just like me (although I am just a beginner on the way of being a console freak), we do our daily jobs with console and emacs, so we need strong scripts to simplify our tasks. Ant (you know what Ant is) from Apache helps a lot. At this point you would probably know the intention what I am going to tell in this introduction.
List of things you need:
- No need to say Ant, I was using v1.7, so previous versions are not guaranteed(though probably work).
- JDK for linux, I was using v1.6, previous versions will probably work, you could know the reason at below.
- WTK, I used v2.5.2, I guess version won't hurt anything.
- JDE from RIM, mine was a v4.1 cause I own only an almost out-of-date 7290 whose highest OS is v4.1
- and... something essential, Linux OS(proudly to announce mine is a Slackware V12 based), emacs, vi or any text editor you like.
WHAT'S NOT NEEDED? AN IDE, PERIOD.
The build.xml
I think you could learn something from the source, so I won't give too much detail, all at your hands.
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is an Apache-Ant project build configuration file for LogicMail
Author: Harry Li <harryl.byread {at} gmail.com>
Date: Jan 19th 2008
-->
<project name="LogicMail" basedir="." default="help">
<!-- set global properties for this build -->
<property name="src.dir" location="../src" />
<property name="build.dir" location="build" />
<property name="class.dir" location="build/class" />
<property name="prev.dir" location="build/prev" />
<property name="dist.dir" location="dist" />
<property name="jde.home" location="jde_home" />
<property name="wtk.home" location="wtk_home" />
<property name="bblib" value="jde_home/lib/net_rim_api.jar" />
<property name="project.name" value="LogicMail" />
<property name="major.ver" value="0" />
<property name="minor.ver" value="3" />
<property name="build.ver" value="2" />
<property name="jar.size" value="0" />
<target name="init">
<tstamp/>
<mkdir dir="${build.dir}" />
<mkdir dir="${class.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${prev.dir}/icons" />
</target>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${class.dir}"
bootclasspath="${bblib}"
target="1.1" source="1.3" />
</target>
<target name="preverify" depends="compile">
<exec executable="${wtk.home}/bin/preverify1.1">
<arg line="-classpath ${bblib}" />
<arg line="-d ${prev.dir}" />
<arg line="${class.dir}" />
</exec>
</target>
<target name="jar" depends="compile">
<copy file="MANIFEST.MF" tofile="${build.dir}/MANIFEST.MF">
<filterset>
<filter token="LOGIC_MAIL_MAJOR_VER" value="${major.ver}"/>
<filter token="LOGIC_MAIL_MINOR_VER" value="${minor.ver}"/>
<filter token="LOGIC_MAIL_BUILD_VER" value="${build.ver}"/>
</filterset>
</copy>
<copy todir="${prev.dir}/icons">
<fileset dir="${src.dir}/icons"/>
</copy>
<jar basedir="${prev.dir}"
jarfile="${build.dir}/${project.name}.jar"
manifest="${build.dir}/MANIFEST.MF" />
<length file="${build.dir}/${project.name}.jar" property="jar.size" />
<copy file="${project.name}.template.jad" tofile="${build.dir}/${project.name}.jad">
<filterset>
<filter token="LOGIC_MAIL_MAJOR_VER" value="${major.ver}" />
<filter token="LOGIC_MAIL_MINOR_VER" value="${minor.ver}" />
<filter token="LOGIC_MAIL_BUILD_VER" value="${build.ver}" />
<filter token="LOGIC_MAIL_JAR_SIZE" value="${jar.size}" />
</filterset>
</copy>
</target>
<target name="rapc" depends="jar">
<exec executable="java">
<arg line="-cp ${jde.home}/bin/rapc.jar net.rim.tools.compiler.Compiler" />
<arg line="import=${bblib} codename=${project.name}" />
<arg line="jad=${build.dir}/${project.name}.jad ${build.dir}/${project.name}.jar"/>
</exec>
</target>
<target name="dist" depends="rapc">
<move todir="${dist.dir}">
<fileset dir=".">
<include name="${project.name}*" />
<exclude name="${project.name}.template.jad" />
</fileset>
<fileset dir="${build.dir}">
<include name="${project.name}.jad"/>
</fileset>
</move>
<move file="${dist.dir}/${project.name}.cod" tofile="${dist.dir}/${project.name}_code.zip" />
<unzip src="${dist.dir}/${project.name}_code.zip" dest="${dist.dir}" />
<delete>
<fileset dir="${dist.dir}">
<include name="*.debug" />
<include name="*.zip" />
<include name="*.cso" />
</fileset>
</delete>
</target>
<target name="build" depends="init,compile,preverify,jar,rapc,dist">
</target>
<target name="help" description="Display help information on how to build">
<echo>Apache Ant build tool for project LogicMail
Usage:
ant help
ant build
ant clean
</echo>
</target>
</project>
Something to note
Although you could learn a lot from the source above, yet something need to explain if you want to get it work correctly.
See
<property name="src.dir" location="../src" />
I created a directory $SVNROOT/trunck/LogicMail/antproject, which is a folder shares the same parent with source folder, so in this sub-directory holding the Ant build files and others related, we call the source from "../src".
See
<property name="jde.home" location="jde_home" />
<property name="wtk.home" location="wtk_home" />
Thats the points we utilize the library and RIM's special compiler from JDE, also preverify tool from WTK. For the sake of portability, I just used direct sub-directory names under $SVNROOT/trunk/LogicMail/antproject, which will be $SVNROOT/trunk/LogicMail/antproject/jde_home and $SVNROOT/trunk/LogicMail/antproject/wtk_home. Then here comes the magic, if you installed your JDE at /mnt/win_drive/Program Files/Research In Motion/BlackBerry JDE 4.1.0/, just do a symbol link at our antproject sub-directory.
ln -s "/mnt/win_drive/Program Files/Research In Motion/BlackBerry JDE 4.1.0/" jde_home
And do the same with WTK home directory. I guess it's the Apple's Time Machine gave me the idea to use symbol link so much, recently :P
Finale
I made this article inspired by BlackBerry Development with Ant & Eclipse, RIM BlackBerry JDE on Linux , and Managing Wireless Builds with Ant. I refused using bb-ant-tools which is a very amazing tool for building BlackBerry software with Apache Ant, cause I want to learn something myself, and get more control besides the rapc compiler integration. But I should admit I got inspiration about how to use the rapc compiler from the source of bb-ant-tools.
The build.xml was verified to work without problem, and the result jar/jad/cod was uploaded to somewhere then tested.
Hope this article could give you some informative inspirations.
Attachments
-
MANIFEST.MF
(299 bytes) - added by kcome
2 years ago.
MANIFEST.MF you need
-
LogicMail.template.jad
(437 bytes) - added by kcome
2 years ago.
LogicMail.template.jad you need
