Create Project
This document describes how to create a new project that uses the JavaRosa code base.
NOTE: This document is outdated. Please do not follow this. It will be updated after the refactoring is complete.
I'm bound to take some incorrect steps.
Step-by-step
- Checkout a copy of the JavaRosa code into your workspace. Make sure that you can compile and run the code (meaning you have the wtk and j2me polish setup)
- Select File -> New Project
- On the Projects tab, select the JavaProtocolSupport project as a required project on the build path
- On the Libraries tab, add the j2me polish libraries (from the import folder in the j2me polish directory). Should have:
- cldc-1.1-java5
- enough-j2mepolish-client
- fileconnection
- midip-2.0
- mmapi
- nokia-ui
- wmapi
- Click finish to create the project (Note that these Eclipse configurations are merely for having the IDE set up properly for writing code. All settings for the actual project build are contained in the build.xml Ant script)
- Create the following folders in the base of your project:
- lib
- resources
- configuration
- Create the file configuration.properties in the configuration directory and add the following:
# place basic configuration properties here, e.g. cfg.enableServerStorage=false
- Create a build.xml file (example at end of page)
- Create a build.properties file (example at end of page)
build.properties
app.name=PolishedMobileMRSDemo
app.version=1.0.0
app.vendor=Dimagi
app.jarName=${app.name}.jar
app.description=
#app.class=org.celllife.clforms.TransportShell
#app.class=org.dimagi.chatscreen.ChatScreenMIDlet
#app.class=org.dimagi.polishforms.ChatScreenMidlet
#app.class= org.javarosa.clforms.TransportShell
app.class= edu.washington.commcare.Shell
app.infoUrl=http\://www.dimagi.com
#The following should be uncommented on devices with File System Access
#app.usefileconnections=true
dir.src=${basedir}/src
dir.test=${basedir}/test
dir.lib=${basedir}/lib
dir.build=${basedir}/build
dir.dist=${basedir}/dist
dir.work=${dir.build}/real/${customization}
dir.resources=${basedir}/resources
build.number=47
polish.home=C:\\Program Files\\J2ME-Polish\\
wtk.home=C:\\WTK2.5.2\\
#device.identifier=Palm/TungstenC
#device.identifier=Generic/DefaultColorPhone
#device.identifier=Generic/MppPhone
#device.identifier=Palm/Treo650
device.identifier=Generic/Midp2Cldc11Pointer
customization=
deploy-url=
palm.weme.home=C:\Program Files\Palm\PalmOS JVM 5.7.2
palm.simulator.home=C:\Program Files\Palm\PalmOS_Garnet_51_Simulator
polish.MenuBar.useExtendedMenuBar="true"
polish.MenuBar.PaddingLeft=3
polish.MenuBar.PaddingRight=3
polish.MenuBar.PaddingTop=3
polish.MenuBar.PaddingBottom=3
#The following should be uncommented on devices with physical keyboards (kind of)
#polish.TextField.useDirectInput=true
build.xml
<project name="blank" default="emulator">
<!-- import user specific properties -->
<property file="${basedir}/build.properties" />
<!-- import global properties -->
<property file="${polish.home}/global.properties" />
<!-- Definition of the J2ME Polish task: -->
<taskdef name="j2mepolish" classname="de.enough.polish.ant.PolishTask" classpath="${polish.home}/lib/enough-j2mepolish-build.jar:${polish.home}/lib/jdom.jar:${polish.home}/lib/j2me-lib_1.1.jar:${polish.home}/lib/microewt_0.92.jar:${polish.home}/lib/microEWT-Examples.jar:${wtk.home}/lib/jsr082.jar" />
<!-- Definition of the Test Suite Name: -->
<property name="test.class.name" value="org.dimagi.ExampleTestCase" />
<!-- Initialization for the build targets -->
<target name="init">
<property name="test" value="false" />
<!-- incriment build number
<propertyfile file="${basedir}/build.properties">
<entry key="build.number" type="int" operation="+" value="1" pattern="00" />
</propertyfile>
<echo message="Build ${build.number}" />
-->
</target>
<!-- This is the main work target, it actually builds the code -->
<target name="j2mepolish" depends="init" description="This is the controller for the J2ME build process.">
<j2mepolish>
<info name="${app.name}"
version="${app.version}"
description="${app.description}"
vendorName="${app.vendor}"
infoUrl="${app.infoUrl}"
jarName="${app.jarName}"
jarUrl="${deploy-url}${app.jarName}" copyright="" />
<!-- selection of supported devices, set this in build.properties -->
<deviceRequirements>
<requirement name="Identifier" value="${device.identifier}" />
</deviceRequirements>
<!-- build settings -->
<!-- 'menu' here designates that we're using the fullscreen Polish UI with native menus -->
<!-- We should see if we can set these first two attributes as properties instead-->
<build fullscreen="menu"
usePolishGui="true"
workDir="${dir.work}"
destDir="${dir.dist}"
binaryLibraries="${dir.lib}">
<!-- midlets definition -->
<midlet class="${app.class}" name="${app.name}" />
<!-- Code source files to include in compilation -->
<sources>
<source dir="${dir.src}"/>
<!--Taking this out for now...-->
<!--source dir="${dir.test}"/-->
</sources>
<!-- Build variables -->
<variables includeAntProperties="true">
<variable file="configuration/configuration.properties" />
<!-- Sets the extended menu bar for polish. Extra memory overhead, but might be useful on some platforms-->
<variable name="polish.MenuBar.useExtendedMenuBar" value="true" />
</variables>
<!-- Resources that should be used in the Polish build (images, the polish.css file, etc) -->
<resources
dir="${dir.resources}"
defaultexcludes="yes"
excludes="readme.txt">
<!-- Set the language for the strings in the application -->
<localization>
<locale name="en" />
</localization>
</resources>
<!-- Whether to run the obfuscator, which makes reverse engineering the byte-code
more difficult, and compresses the built JAR -->
<!-- obfuscator settings: do not obfuscate when the test-property is true -->
<obfuscator name="ProGuard" unless="test">
<parameter name="optimize" value="true" />
</obfuscator>
<!-- log settings: only use debug setting when the test-property is true -->
<debug if="test" showLogOnError="true" verbose="true" level="error">
<filter pattern="org.celllife.clforms.*" level="debug" />
</debug>
<!-- Properties of the actual javac compiler -->
<compiler classpath="${polish.home}/import/fileconnection.jar:${polish.home}/import/j2me-lib_1.1.jar:${polish.home}/import/microewt_0.92.jar:${wtk.home}/lib/jsr082.jar"/>
</build>
<!-- execution of emulator(s) -->
<emulator wait="true" securityDomain="trusted" enableProfiler="true" enableMemoryMonitor="true" enableNetworkMonitor="false" if="debug">
<!--debugger name="antcall" target="connect-debugger" port="6001" /-->
</emulator>
<emulator wait="true" trace="none" securityDomain="trusted" enableProfiler="false" enableMemoryMonitor="false" enableNetworkMonitor="false" if="test and not debug">
</emulator>
</j2mepolish>
</target>
<!-- Sets the 'debug' ANT variable to true -->
<target name="enableDebug">
<property name="debug" value="true" />
</target>
<!-- Enables the emulator by setting 'test' to be true, and setting a working directory -->
<target name="enableEmulator">
<property name="test" value="true" />
<property name="dir.work" value="build/test" />
</target>
<!-- Builds the code and invokes the emulator -->
<target name="emulator" depends="enableEmulator,j2mepolish" description="invokes the emulator">
</target>
<!-- The location of the directory containing tests -->
<property name="tst-dir" location="test/" />
<property name="TALK" value="true" />
<path id="classpath.base">
</path>
<!-- Note that most of this testing code was here to test our auto-integration tester, and isn't actually
usable for testing J2ME code -->
<!-- The classpath that should be used for tests -->
<path id="classpath.test">
<pathelement location="${tst-dir}/lib/junit.jar" />
<pathelement location="${tst-dir}" />
<path refid="classpath.base" />
</path>
<!-- Compiles the source including tests -->
<target name="compile-test">
<javac srcdir="${tst-dir}"
verbose="${TALK}"
>
<classpath refid="classpath.test"/>
</javac>
</target>
<!-- Cleans the test directory and re-compile -->
<target name="clean-compile-test">
<delete verbose="${TALK}">
<fileset dir="${tst-dir}" includes="**/*.class" />
</delete>
</target>
<!-- Cleans directories created by a build -->
<target name="clean" description="allows a clean build. You should call [ant clean] whenever you made changes to devices.xml, vendors.xml or groups.xml">
<delete dir="build" />
<delete dir="dist" />
</target>
<!-- Cleans, and then runs the build target -->
<target name="cleanbuild" description="allows a clean build. You should call [ant cleanbuild] whenever you made changes to devices.xml, vendors.xml or groups.xml" depends="clean, j2mepolish" />
<!-- Cleans, and then runs the build target with the emulator -->
<target name="cleanbuildemulator" description="allows a clean build. You should call [ant cleanbuild] whenever you made changes to devices.xml, vendors.xml or groups.xml" depends="clean, enableEmulator, j2mepolish" />
<!-- Runs the build with all debug properties enabled -->
<target name="debug" description="debugs the project" depends="enableDebug, enableEmulator, j2mepolish" />
</project>
