forked from getodk/collect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
419 lines (350 loc) · 14.5 KB
/
build.gradle
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
apply plugin: 'com.android.application'
apply from: '../config/quality.gradle'
apply from: '../config/jacoco.gradle'
apply plugin: 'kotlin-android'
import com.android.ddmlib.DdmPreferences
import dependencies.Dependencies
import dependencies.Versions
DdmPreferences.setTimeOut(60000)
ant.condition(property: 'os', value: 'windows') {
os(family: 'windows')
}
ant.condition(property: 'os', value: 'unix') {
os(family: 'unix')
}
// Build numbers were manually set until 1067
def LEGACY_BUILD_NUMBER_OFFSET = 1067
// Based on https://stackoverflow.com/questions/17097263#24121734
def getMasterCommitCount = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
switch (ant.properties.os) {
case 'windows':
commandLine 'cmd', '/c', 'git', 'rev-list', '--first-parent', '--count', 'master'
break
case 'unix':
commandLine 'git', 'rev-list', '--first-parent', '--count', 'master'
break
}
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
} catch (ignored) {
return -1
}
}
def getVersionName = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
switch (ant.properties.os) {
case 'windows':
commandLine 'cmd', '/c', 'git', 'describe', '--tags', '--dirty', '--always'
break
case 'unix':
commandLine 'git', 'describe', '--tags', '--dirty', '--always'
break
}
standardOutput = stdout
}
return stdout.toString().trim()
} catch (ignored) {
return null
}
}
def secrets = getSecrets()
def googleMapsApiKey = secrets.getProperty('GOOGLE_MAPS_API_KEY', '')
def mapboxAccessToken = secrets.getProperty('MAPBOX_ACCESS_TOKEN', '')
android {
compileSdkVersion Versions.android_compile_sdk
buildFeatures {
viewBinding true
}
defaultConfig {
applicationId('org.odk.collect.android')
minSdkVersion Versions.android_min_sdk
targetSdkVersion Versions.android_target_sdk
versionCode LEGACY_BUILD_NUMBER_OFFSET + getMasterCommitCount()
versionName getVersionName()
testInstrumentationRunner('androidx.test.runner.AndroidJUnitRunner')
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
archivesBaseName = 'collect'
}
signingConfigs {
release {
if (secrets.getProperty('RELEASE_STORE_FILE')) {
storeFile file(secrets.getProperty('RELEASE_STORE_FILE'))
storePassword secrets.getProperty('RELEASE_STORE_PASSWORD')
keyAlias secrets.getProperty('RELEASE_KEY_ALIAS')
keyPassword secrets.getProperty('RELEASE_KEY_PASSWORD')
}
}
selfSignedRelease {
storeFile file('../debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
// Release build for all forks
release {
if (secrets.getProperty('RELEASE_STORE_FILE')) {
signingConfig signingConfigs.release
}
minifyEnabled(true)
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
resValue("string", "GOOGLE_MAPS_API_KEY", googleMapsApiKey)
resValue("string", "mapbox_access_token", mapboxAccessToken)
}
// Release build for the official ODK Collect app
odkCollectRelease {
if (secrets.getProperty('RELEASE_STORE_FILE')) {
signingConfig signingConfigs.release
}
minifyEnabled(true)
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
resValue("string", "GOOGLE_MAPS_API_KEY", googleMapsApiKey)
resValue("string", "mapbox_access_token", mapboxAccessToken)
matchingFallbacks = ['release'] // So other modules use release build type for this
}
selfSignedRelease {
signingConfig signingConfigs.selfSignedRelease
minifyEnabled(true)
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
resValue("string", "GOOGLE_MAPS_API_KEY", googleMapsApiKey)
resValue("string", "mapbox_access_token", mapboxAccessToken)
matchingFallbacks = ['release'] // So other modules use release build type for this
}
debug {
debuggable(true)
testCoverageEnabled((findProperty("enableJacoco") ?: "false").toBoolean())
resValue("string", "GOOGLE_MAPS_API_KEY", googleMapsApiKey)
resValue("string", "mapbox_access_token", mapboxAccessToken)
}
}
// https://stackoverflow.com/a/27119543/152938
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = new File(outputFileName.replace(".apk", "-${defaultConfig.versionName}.apk"))
}
}
testVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = new File(outputFileName.replace(".apk", "-${defaultConfig.versionName}.apk"))
}
}
packagingOptions {
resources {
// These library licenses will be referenced in-app
excludes += ['META-INF/ASL-2.0.txt', 'META-INF/LGPL-3.0.txt']
// Pick first occurrence of any files that cause conflicts
pickFirsts += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/LICENSE.txt', 'META-INF/NOTICE', 'META-INF/NOTICE.txt', 'META-INF/services/com.fasterxml.jackson.core.JsonFactory', 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec', 'META-INF/services/javax.ws.rs.ext.MessageBodyReader', 'META-INF/services/javax.ws.rs.ext.MessageBodyWriter', 'draftv4/schema', 'draftv3/schema']
}
// To ensure that ODK Collect is installable on all devices, we don't use
// abiFilters to exclude any ABIs; but to keep the APK slim, we include
// the Mapbox native library only for 32-bit and 64-bit ARM devices and
// omit it for all X86 devices.
if (!project.hasProperty("x86Libs")) {
exclude 'lib/x86/libmapbox-maps.so'
exclude 'lib/x86/libmapbox-common.so'
exclude 'lib/x86/libc++_shared.so'
exclude 'lib/x86_64/libmapbox-maps.so'
exclude 'lib/x86_64/libmapbox-common.so'
exclude 'lib/x86_64/libc++_shared.so'
}
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
testOptions {
unitTests {
includeAndroidResources = true
returnDefaultValues = true
all {
minHeapSize = '512m'
maxHeapSize = project.properties['test.heap.max']
}
}
}
sourceSets {
androidTest {
java.srcDirs += "src/commonTest/java"
}
test {
java.srcDirs += "src/commonTest/java"
}
}
lint {
abortOnError true
checkDependencies true
checkGeneratedSources true
htmlReport true
lintConfig file("$rootDir/config/lint.xml")
xmlReport true
}
namespace 'org.odk.collect.android'
}
configurations.all {
resolutionStrategy {
cacheDynamicVersionsFor(0, 'seconds')
cacheChangingModulesFor(0, 'seconds')
force 'org.objenesis:objenesis:2.6'
}
transitive = true
}
dependencies {
repositories {
mavenLocal() // Only used for javarosa_local dependency
}
coreLibraryDesugaring Dependencies.desugar
implementation project(':shared')
implementation project(':androidshared')
implementation project(':nbistubs')
implementation project(':icons')
implementation project(':strings')
implementation project(':material')
implementation project(':async')
implementation project(':analytics')
implementation project(':audioclips')
implementation project(':forms')
implementation project(':audiorecorder')
implementation project(':projects')
implementation project(':location')
implementation project(':geo')
implementation project(':imageloader')
implementation project(':errors')
implementation project(':upgrade')
implementation project(':permissions')
implementation(project(':settings')) {
exclude group: 'joda-time'
}
implementation project(':externalapp')
implementation project(':maps')
implementation project(':osmdroid')
if (getSecrets().getProperty('MAPBOX_DOWNLOADS_TOKEN', '') != '') {
implementation project(':mapbox')
}
implementation Dependencies.androidx_startup
implementation Dependencies.androidx_core_ktx
implementation Dependencies.androidx_browser
implementation Dependencies.androidx_appcompat
implementation Dependencies.androidx_work_runtime
implementation Dependencies.androidx_cardview
implementation Dependencies.androidx_exinterface
implementation Dependencies.androidx_multidex
implementation Dependencies.androidx_preference_ktx
implementation Dependencies.androidx_fragment_ktx
implementation Dependencies.android_material
implementation Dependencies.android_flexbox
implementation Dependencies.play_services_auth
implementation Dependencies.play_services_maps
implementation Dependencies.play_services_location
implementation Dependencies.firebase_analytics
implementation Dependencies.firebase_crashlytics
implementation Dependencies.guava
implementation Dependencies.squareup_okhttp
implementation Dependencies.squareup_okhttp_tls
implementation Dependencies.burgstaller_okhttp_digest
implementation Dependencies.persian_joda_time
implementation Dependencies.myanmar_calendar
implementation Dependencies.bikram_sambat
implementation Dependencies.rarepebble_colorpicker
implementation Dependencies.commons_io
implementation (Dependencies.opencsv) {
exclude group: 'commons-logging'
}
implementation(Dependencies.javarosa) {
exclude group: 'commons-io'
exclude group: 'joda-time'
exclude group: 'org.slf4j'
exclude group: 'org.hamcrest', module: 'hamcrest-all'
}
implementation(Dependencies.google_api_client_android) {
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.google.guava'
}
implementation(Dependencies.google_api_services_drive) {
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.google.guava'
}
implementation(Dependencies.google_api_services_sheets) {
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.google.guava'
}
implementation Dependencies.timber
implementation Dependencies.slf4j_api
implementation Dependencies.slf4j_timber
implementation Dependencies.zxing_android_embedded
implementation Dependencies.danlew_android_joda
// Android Architecture Components:
implementation Dependencies.androidx_lifecycle_extensions
implementation Dependencies.androidx_lifecycle_runtime_ktx
implementation Dependencies.androidx_viewpager2
// Dagger:
implementation Dependencies.dagger
annotationProcessor Dependencies.dagger_compiler
// Needed for injection into Robolectric tests
testAnnotationProcessor Dependencies.dagger_compiler
// Dagger Android:
implementation Dependencies.dagger_android
annotationProcessor Dependencies.dagger_android_processor
implementation Dependencies.armen101_audio_recorder_view
implementation(Dependencies.mp4parser_muxer) {
exclude group: 'org.hamcrest'
}
implementation Dependencies.splashscreen
testImplementation project(':formstest')
// Testing-only dependencies
testImplementation Dependencies.junit
testImplementation Dependencies.mockito_core
testImplementation Dependencies.mockito_inline
testImplementation Dependencies.mockito_kotlin
testImplementation project(':androidtest')
testImplementation(project(path: ':testshared')) {
exclude group: 'org.robolectric' // Some tests in `collect_app` don't work with newer Robolectric
}
testImplementation Dependencies.robolectric
testImplementation Dependencies.androidx_test_ext_junit
testImplementation Dependencies.androidx_arch_core_testing
testImplementation Dependencies.robolectric_shadows_multidex
testImplementation Dependencies.okhttp3_mockwebserver
testImplementation Dependencies.squareup_okhttp_tls
testImplementation Dependencies.hamcrest
testImplementation Dependencies.androidx_test_espresso_core
testImplementation Dependencies.androidx_test_espresso_intents
testImplementation Dependencies.androidx_test_core_ktx
androidTestImplementation project(':androidtest')
// Used to generate documentation screenshots.
androidTestImplementation Dependencies.fastlane_screengrab
androidTestImplementation Dependencies.mockito_android
androidTestImplementation Dependencies.androidx_test_ext_junit
androidTestImplementation Dependencies.androidx_test_espresso_core
androidTestImplementation Dependencies.androidx_arch_core_testing
androidTestImplementation Dependencies.androidx_test_espresso_contrib
androidTestImplementation(Dependencies.androidx_test_espresso_intents) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation Dependencies.okhttp3_mockwebserver
androidTestImplementation Dependencies.androidx_work_testing
androidTestImplementation Dependencies.uiautomator
debugImplementation project(':fragmentstest')
debugImplementation(project(':testshared')) {
exclude group: 'org.robolectric' // Some tests in `collect_app` don't work with newer Robolectric
}
// Real LeakCanary for debug builds only: notifications, analysis, etc
debugImplementation Dependencies.leakcanary
}
// Must be at bottom to prevent dependency collisions
// https://developers.google.com/android/guides/google-services-plugin
apply plugin: 'com.google.gms.google-services'
// Must be after google-services to prevent build failure
// https://stackoverflow.com/a/67995305