~lifeeth/sahana-eden/mobile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<!-- The JavaRosa build script is structured as follows:
     Modifiable properties are stored in the external build.properties file
     The classpath for external jars is defined in the Build taskdef

     NOTE: Binary Libraries (.zip is the convention in j2me) are declared
     seperately in the binaryLibraries property. Not on the classpath!

     The BuildPolish target is associated with building the jar/jad files

     All other non-test targets essentially modify properties associated with the
     Build target
-->
<project name="JavaRosa" default="LaunchEmulator">
	<!-- Main Target: Call to build the project -->
	<!-- This is the main work target, it actually builds the code -->
	<target name="BuildPolish" depends="init" description="This is the controller for the J2ME build process.">
		
		<!-- Since the <libraries> call won't filter, we have to do so ahead of time. -->
		<mkdir dir="${dir.lib.working}"/>
		<copy todir="${dir.lib.working}">
			<fileset dir="${dir.lib}">
				<exclude name=".svn"/>
			</fileset>
		</copy>
		
		<!-- A property containing the path to the preprocessed source files -->
		<property name="builtsource" value="${dir.build}/real/${device.identifier}/none/source/" />
		<buildPolish>
			<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}" />
<!-- 				<requirement name="JavaPackage" value="nokia-ui" /> -->
<!--                                 <requirement name="Term" value="polish.api.nokia-ui and polish.midp2" /> -->

			</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="${javarosa.usepolishui}"
				workDir="${dir.work}"
				destDir="${dir.dist}">
				
				<libraries>
					<library dir="${dir.lib.working}" />
				</libraries>

				<!-- midlets definition -->
				<midlet class="${app.class}" name="${app.name}" />

				<!-- Code source files to include in compilation -->
				<!-- All source-level inclusions should be made here -->
				<sources>
					<source dir="${dir.src}"/>
					<source dir="${basedir}/../org.javarosa.communication/src/"/>
					<source dir="${basedir}/../org.javarosa.formmanager/src/"/>
					<source dir="${basedir}/../org.javarosa.services.properties/src/"/>
					<source dir="${dir.common}/org.javarosa.communication.ui/src/"/>
					<source dir="${dir.common}/org.javarosa.core/src/"/>
					<source dir="${dir.common}/org.javarosa.core.model/src/"/>
					<source dir="${dir.common}/org.javarosa.forms/src/"/>
					<source dir="${dir.common}/org.javarosa.j2me/src/"/>					
					<source dir="${dir.common}/org.javarosa.polish.chatterbox/src/"/>
					<source dir="${dir.common}/org.javarosa.resources/src/"/>
					<source dir="${dir.common}/org.javarosa.user/src/"/>
					<source dir="${dir.common}/org.javarosa.utilities.file/src/"/>
					<source dir="${dir.common}/org.javarosa.xform/src/"/>					
					<source dir="${dir.common}/org.javarosa.entity/src/"/>
				</sources>

				<!-- Build variables -->
				<variables includeAntProperties="true">
					<variable file="configuration/configuration.properties" />
				</variables>

				<!-- Resources that should be used in the Polish build (images, the polish.css file, etc) -->
				<resources
					dir="${dir.resources}"
					defaultexcludes="no"
					excludes="readme.txt, .svn, *.css, .bzr">
					<root dir="${dir.resources.external}"
						excludes=".svn"/>
					<!-- Set the language for the strings in the application -->
					<localization>
						<locale name="none" />
					</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="(noobfuscate or test) and not release">
					<parameter name="optimize" value="true" />
					<parameter name="printmapping" value="'${dir.dist}/obfuscation_mapping.txt'" />
					
					<!-- none of the parameter names below can be the same, or else they will clobber previous parameters; hence the varied spacing -->
					<parameter name="keep,allowshrinking" value="!abstract class org.javarosa.core.model.* implements org.javarosa.core.model.IFormElement" />
					<parameter name="keep, allowshrinking" value="!abstract class org.javarosa.core.model.instance.* implements org.javarosa.core.model.IFormDataModel" />
					<parameter name="keep ,allowshrinking" value="!abstract class org.javarosa.core.model.data.* implements org.javarosa.core.model.data.IAnswerData" />
					<parameter name="keep,  allowshrinking" value="!abstract class org.javarosa.model.xform.* implements org.javarosa.core.model.IDataReference" />
					<parameter name="keep     " value="!abstract class org.javarosa.xpath.* implements org.javarosa.core.model.condition.IConditionExpr" />
					<parameter name="keep , allowshrinking" value="!abstract class org.javarosa.xpath.* implements org.javarosa.core.model.condition.IConditionExpr" />
					<parameter name="keep" value="!abstract class org.javarosa.xpath.expr.* extends org.javarosa.xpath.expr.XPathExpression" />
					<parameter name="keep  ,allowshrinking" value="!abstract class org.javarosa.xpath.expr.* extends org.javarosa.xpath.expr.XPathExpression" />
					<parameter name="keep,   allowshrinking" value="!abstract class org.javarosa.communication.** implements org.javarosa.core.services.transport.ITransportDestination"/>
					<parameter name="keep " value="!abstract class org.javarosa.** implements org.javarosa.core.services.transport.IDataPayload"/>
					<parameter name="keep,    allowShrinking" value="!abstract class org.javarosa.** implements org.javarosa.core.services.transport.IDataPayload"/>
					<parameter name="keep  " value="!abstract class org.javarosa.** implements org.javarosa.core.data.IDataPointer"/>
					<parameter name="keep,     allowShrinking" value="!abstract class org.javarosa.** implements org.javarosa.core.data.IDataPointer"/>
					<parameter name="keep  ,   allowShrinking" value="class org.javarosa.model.GraphDataGroup"/>
					<parameter name="keep      " value="!abstract class org.javarosa.** implements org.javarosa.core.services.locale.LocaleDataSource"/>
					<parameter name="keep   ,     allowShrinking" value="!abstract class org.javarosa.** implements org.javarosa.core.services.locale.LocaleDataSource"/>
				</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 debug="on" classpath="${polish.home}/import/enough-j2mepolish-client.jar:${polish.home}/import/fileconnection.jar:${polish.home}/import/j2me-lib_1.1.jar:${wtk.home}/lib/jsr082.jar:${polish.home}/import/nokia-ui.jar:${polish.home}/import/m3g.jar:${polish.home}/import/wmapi.jar"/>
				
				<!--postcompiler name="java5" /-->
				<!-- Add back when we're satisfied with everyone using it -->

			</build>

			<!-- execution of emulator(s) -->
			<!-- Target one: Run emulator and profiling tools if debugging is enabled -->
			<emulator wait="true" securityDomain="trusted" enableProfiler="true" enableMemoryMonitor="true" enableNetworkMonitor="false" if="debug">
				<!-- Enable the following line to test memory constraints on the device -->
				<!--parameter name="-Xheapsize" value="2897152"/-->
			</emulator>

			<!-- Target two: Run emulator only, with no profiling tools if debugging is disabled but testing is -->
			<emulator wait="true" trace="none" securityDomain="trusted" enableProfiler="false" enableMemoryMonitor="false" enableNetworkMonitor="false" if="test and not debug">
				<!-- Enable the following line to test memory constraints on the device -->
				<!--parameter name="-Xheapsize" value="2897152"/-->
				<!--debugger port="6001" /-->
			</emulator>

		</buildPolish>
		<!-- Clean up our temporary directory -->
		<delete dir="${dir.lib.working}"/>
	</target>

	<!-- Main Target: Call to build the project and call up the emulator -->
	<!-- Builds the code and invokes the emulator -->
	<target name="LaunchEmulator" depends="enableEmulator,BuildPolish" description="invokes the emulator">
	</target>

	<!-- Main Target: Call to clean 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" />
		<delete dir="lib.working" />
	</target>
	<target name="clean" depends="Clean" description="Alias for Clean">
	</target>	
	<!-- Main Target: Call to clean the emulator's RMS -->
	<target name="CleanRMS" description="cleans the emulator's database">
		<delete dir="${j2mewtk.home}/appdb/DefaultColorPhone"/>
	</target>
	
	<!-- Main Target: Cleans, and then runs the build target -->
	<target name="BuildClean" description="allows a clean build. You should call [ant cleanbuild] whenever you made changes to devices.xml, vendors.xml or groups.xml" depends="Clean, BuildPolish"/>
	
	<!-- Main Target: Cleans, enables all release configurations and runs the build target -->
	<target name="BuildRelease" description="allows a clean build. You should call [ant cleanbuild] whenever you made changes to devices.xml, vendors.xml or groups.xml" depends="Clean, enableRelease, BuildPolish"/>

	<!-- Main Target: Cleans, and then runs the build target with the emulator -->
	<target name="BuildCleanRunEmulator" description="allows a clean build, and then launches the emulator" depends="Clean, enableEmulator, BuildPolish" />

	<!-- Main Target: Runs the build with all debug properties enabled -->
	<target name="LaunchEmulatorAndProfilers" description="debugs the project" depends="enableDebug, enableEmulator, BuildPolish" />

	<target name="CreateJavadoc" depends="BuildClean" description="generates javadoc and also UML Diagram">
		<mkdir dir="${dir.javadoc}"/>
	        <javadoc useexternalfile="yes" sourcepath="${builtsource}" packagenames="org.javarosa.*" destdir="${dir.javadoc}"
	        	classpathref="classpath.test" private="true">
	        	   <doclet name="org.umlgraph.doclet.UmlGraphDoc" path="${dir.tools}/UmlGraph.jar" >
	        	        <param name="-attributes" />
	        	        <param name="-operations" />
	        	        <param name="-qualify" />
	        	        <param name="-types" />
	        	        <param name="-visibility" />
	        	    </doclet>	
	        	    <link href="http://java.sun.com/javame/reference/apis/jsr030/"/>
	        	    <link href="http://java.sun.com/javame/reference/apis/jsr118/"/>
	        	    <link href="http://www.j2mepolish.org/javadoc/j2me/"/>
	        	  </javadoc>
		  <apply executable="dot" dest="${dir.documentation}" parallel="false">
		    <arg value="-Tpng"/>
		    <arg value="-o"/>
		     <targetfile/>
		     <srcfile/>
		     <fileset dir="${dir.documentation}" includes="*.dot"/>
		     <mapper type="glob" from="*.dot" to="*.png"/>
		  </apply>
	</target>
	
	<target name="DecomposeJar" depends="BuildClean">
		<!--exec executable="python" failifexecutionfails="false" dir="dist">
			<arg value="../tools/jar_usage.py" />
			<arg value="JavaRosaDemoP.jar" />
			<arg value="obfuscation_mapping.txt" />
		</exec-->
	    <py-run script="${dir.tools}/jar_usage.py" optimize="0" python="${pythonexec}">
	      <arg value="${basedir}\dist\${app.jarName}"/>
	      <arg value="${basedir}\dist\obfuscation_mapping.txt"/>
	    </py-run>
	</target>
	
	<!-- This target should prevent us from needing to re-run BuildClean for additional targets -->
	<target name="BuildServerExtras" depends="BuildClean,CreateJavadoc,DecomposeJar"/>
	      	

	<!-- Initialization for the build targets                    -->
	<target name="init">
		<!-- Disable the Emulator by default -->
		<property name="test" value="false" />
	</target>

	<target name="supressOutput">
		<property name="${debug.output}" value="none"/>
	</target>
	
	<target name="enableRelease">
		<property name="release" value="true"/>
	</target>

	<target name="disableObfuscator">
		<property name="noobfuscate" value="true"/>
	</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>
	

	<target name="build-xpath-parser">
		<ant antfile="${dir.common}/org.javarosa.xform/build.xml" target="build-xpath-parser" dir="${dir.common}/org.javarosa.xform" />
	</target>

	<macrodef name="propertycopy">
	  <attribute name="name"/>
	  <attribute name="from"/>
	  <sequential>
	    <property name="@{name}" value="${@{from}}"/>
	  </sequential>
	</macrodef>

	<!-- import user specific properties                          -->
	<property file="${basedir}/build.properties" />

	<!-- import global properties                                 -->
	<property file="${polish.home}/global.properties" />

	<property name="TALK" value="true" />

	<!-- Definition of the J2ME Polish task:                      -->
	<taskdef name="buildPolish" 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:${polish.home}/import/nokia-ui.jar:${polish.home}/import/m3g.jar" />
	<path id="classpath.base">
	</path>
	

	<!-- Defines the py-run task                                  -->
	<taskdef name="py-run" classname="org.pyant.tasks.PythonRunTask" classpath="${dir.tools}/pyAntTasks-1.2.jar"/>



	<!-- The classpath that should be used for tests -->
	<path id="classpath.test">
	  <pathelement location="${dir.dist}/${app.jarName}"/>
	  <pathelement location="${wtk.home}/lib/wma11.jar"/>
	  <pathelement location="${wtk.home}/lib/midpapi21.jar"/>
	  <path refid="classpath.base" />
	</path>
</project>