forked from thunderbird/thunderbird-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
320 lines (275 loc) · 14.1 KB
/
build.xml
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<?xml version="1.0" encoding="UTF-8"?>
<project name="K9" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: custom -->
<import file="${sdk.dir}/tools/ant/build.xml" />
<!-- K9 CUSTOM STUFF -->
<!-- out folders for a parent project if this project is an instrumentation project -->
<property name="rclib" value="${out.dir}/K9RemoteControl.jar" />
<property name="rcdir" value="com/fsck/k9/remotecontrol/**" />
<condition property="android.executable" value="android.bat">
<os family="windows" />
</condition>
<property name="android.executable" value="android" />
<target name="-get-version" depends="-get-version-name">
<echo>Building version number ${current-version-name}</echo>
</target>
<target name="-get-version-name">
<xpath input="AndroidManifest.xml" expression="/manifest/@android:versionName" output="current-version-name" />
</target>
<target name="-get-version-code">
<xpath input="AndroidManifest.xml" expression="/manifest/@android:versionCode" output="current-version-code" />
</target>
<target name="-get-version-from-git">
<exec executable="git" failonerror="true" outputproperty="current-version-name" errorproperty="current-version-error">
<arg line="describe --tags" />
</exec>
<echo>Building version number ${current-version-name}</echo>
</target>
<target name="-auto-incr-version">
<regex property="major" input="${current-version-name}" regexp="(\d+)\.\d+" select="\1" />
<regex property="minor" input="${current-version-name}" regexp="\d+\.(\d+)" select="\1" />
<math result="minor" operand1="${minor}" operation="+" operand2="1" datatype="int"/>
<if.contrib>
<length string="${minor}" when="eq" length="1" />
<then>
<var name="minor" value="00${minor}" />
</then>
<elseif>
<length string="${minor}" when="eq" length="2" />
<then>
<var name="minor" value="0${minor}" />
</then>
</elseif>
</if.contrib>
<regex property="version-name" input="${major}." regexp="(\d+.)" replace="\1${minor}" />
</target>
<target name="-set-version" depends="-get-version-name,-get-version-code">
<!-- pass -Dversion-name=4.200 to define the version instead of auto-incrementing it -->
<if.contrib>
<isset property="version-name" />
<else>
<runtarget target="-auto-incr-version" />
</else>
</if.contrib>
<echo>Setting version to ${version-name}</echo>
<replace file="AndroidManifest.xml"
token="android:versionName="${current-version-name}""
value="android:versionName="${version-name}"" summary="true"
/>
<math result="new-version-code" operand1="${current-version-code}" operation="+" operand2="1" datatype="int"/>
<replace file="AndroidManifest.xml"
token="android:versionCode="${current-version-code}""
value="android:versionCode="${new-version-code}"" summary="true"
/>
</target>
<!-- rules -->
<target name="bump-version" depends="-set-version,-commit-version">
<echo>Bumped K-9 to ${version-name}</echo>
</target>
<target name="-commit-version">
<exec executable="git" failonerror="true">
<arg line="commit -m'Bumped manifest to ${version-name}' AndroidManifest.xml" />
</exec>
<exec executable="git" failonerror="true">
<arg line="tag ${version-name}" />
</exec>
<exec executable="git" failonerror="true">
<arg line="push" />
</exec>
<exec executable="git" failonerror="true">
<arg line="push origin tag ${version-name}" />
</exec>
</target>
<!-- Create the output directories if they don't exist yet. -->
<target name="rclib" depends="-compile">
<echo>Creating library ${rclib} for remote control applications</echo>
<jar destfile="${rclib}" basedir="${out.classes.dir}" includes="${rcdir}" />
</target>
<target name="upload" depends="clean,-get-version,release">
<echo>Uploading to Google Code using Google::Code::Upload</echo>
<move file="${out.final.file}" tofile="bin/k9-${current-version-name}-release.apk" />
<property name="gcode-project" value="k9mail" />
<exec executable="googlecode_upload.pl" failonerror="true">
<arg value="--summary" />
<arg value="${ant.project.name} ${current-version-name}" />
<arg value="--project" />
<arg value="${gcode-project}" />
<arg value="--user" />
<arg value="${gcode-user}" />
<arg value="--pass" />
<arg value="${gcode-pass}" />
<arg value="--labels" />
<arg value="Type-Installer" />
<arg value="bin/k9-${current-version-name}-release.apk" />
</exec>
</target>
<target name="astyle">
<exec executable="astyle" failonerror="true">
<arg line="--style=java --indent=spaces=4 --indent-switches --max-instatement-indent=4 --brackets=attach --add-brackets --convert-tabs --unpad-paren --pad-header --pad-oper --suffix=none --recursive 'src/com/fsck/k9/*.java' 'tests/src/com/fsck/k9/*.java'" />
</exec>
</target>
<target name="help" depends="android_rules.help">
<!-- displays starts at col 13
|13 80| -->
<echo>Additional targets:</echo>
<!--echo> bump-version: ant -Dversion-name=3.123</echo>
<echo> Bumps the project version to 3.123,tags and commits it.</echo>
<echo> If version-name is not given, it will auto-increment.</echo>
<echo> upload: Uploads a new release to google code.</echo-->
<echo> rclib: Creates library for remote control applications.</echo>
<echo> astyle: Make K-9's source look like it's supposed to.</echo>
<echo> eclipse: Apply template Eclipse settings.</echo>
<echo> javadoc: Javadoc output to javadoc/. ANDROID_HOME environment</echo>
<echo> variable must be set (i.e. /opt/android-sdk-linux/).</echo>
<echo> lint-xml: Lint output lint-results.xml.</echo>
<echo> lint-html: Lint output to lint-results.html.</echo>
<echo> monkey: Runs monkey on the running emulator. Change the</echo>
<echo> defaults -Dmonkey.seed=NUM and -Dmonkey.count=NUM</echo>
<echo> from 0 and 200, respectively.</echo>
</target>
<target name="eclipse" description="Apply template Eclipse settings">
<copy todir=".settings">
<fileset dir="tools/eclipse-settings" />
</copy>
</target>
<target name="monkey">
<xpath input="AndroidManifest.xml" expression="/manifest/@package" output="manifest.package" />
<property name="monkey.count" value="200" />
<property name="monkey.seed" value="0" /><!-- largest == 9223372036854775807 == 2**63 - 1 -->
<exec executable="${adb}" output="monkey.txt" failonerror="true">
<arg line="${adb.device.arg}" />
<arg value="-e" />
<arg value="shell" />
<arg value="monkey" />
<arg value="-p" />
<arg value="${manifest.package}" />
<arg value="-v" />
<arg value="-v" />
<arg value="-s" />
<arg value="${monkey.seed}" />
<arg value="${monkey.count}" />
</exec>
</target>
<target name="reg" depends="-get-version-code">
<regex property="branch" input="${env.GIT_BRANCH}" regexp="(?:.*/)?(.+)" select="\1" global="true"/>
<regex property="commit" input="${env.GIT_COMMIT}" regexp="([\da-fA-F]{10})" select="\1" global="true"/>
<math result="version-code" operand1="${current-version-code}" operation="+" operand2="1" datatype="int"/>
<echo message="branch = ${branch} ${commit} ${current-version-code} ${version-code}" />
</target>
<!-- this is for CloudBees. see tests/build.xml -->
<target name="-artifactd" depends="-set-debug-files, -artifact" />
<target name="-artifacti" depends="-set-instrumented-mode, -artifact" />
<target name="-artifact">
<regex property="branch" input="${env.GIT_BRANCH}" regexp="(?:.*/)?(.+)" select="\1" global="true" />
<regex property="commit" input="${env.GIT_COMMIT}" regexp="([\da-fA-F]{10})" select="\1" />
<copy file="${out.final.file}"
tofile="${out.dir}/${ant.project.name}-${branch}-${env.BUILD_ID}-${commit}-${env.BUILD_NUMBER}.apk"
verbose="on"
/>
</target>
<target name="-pre-clean" description="Removes testing output and javadoc">
<delete file="monkey.txt" verbose="${verbose}" />
<delete file="lint-results.xml" verbose="${verbose}" />
<delete file="lint-results.html" verbose="${verbose}" />
<delete dir="lint-results_files" verbose="${verbose}" />
<delete dir="${javadoc-dir}" verbose="${verbose}" />
</target>
<target name="-update-abs">
<if.contrib>
<resourceexists>
<file file="plugins/ActionBarSherlock/library/build.xml" />
</resourceexists>
<else>
<echo message="android update lib-project -p plugins/ActionBarSherlock/library/" />
<exec executable="${sdk.dir}/tools/${android.executable}" failonerror="true">
<arg line="update lib-project -p plugins/ActionBarSherlock/library/" />
</exec>
</else>
</if.contrib>
</target>
<target name="-update-ptr">
<if.contrib>
<resourceexists>
<file file="plugins/Android-PullToRefresh/library/build.xml" />
</resourceexists>
<else>
<echo message="android update lib-project -p plugins/Android-PullToRefresh/library/" />
<exec executable="${sdk.dir}/tools/${android.executable}" failonerror="true">
<arg line="update lib-project -p plugins/Android-PullToRefresh/library/" />
</exec>
</else>
</if.contrib>
</target>
<target name="init" depends="-update-abs, -update-ptr"
description="Initialize environment for building" />
<!-- overrides default "debug" target" -->
<!-- Builds debug output package -->
<target name="debug" depends="init, -set-debug-files, -do-debug, -post-build"
description="Builds the application and signs it with a debug key.">
</target>
<!-- common to both build.xml and tests/build.xml -->
<import file="build_common.xml" />
<!-- END K-9 CUSTOM STUFF -->
</project>