This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 496
/
build.gradle
440 lines (376 loc) · 16.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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
apply plugin: 'androidx.navigation.safeargs.kotlin'
apply plugin: 'jacoco'
def environmentExtractor = { File path ->
def rawJson = path.text
def escapedJson = rawJson.replace("\"", "\\\"").replace("\n", "").replace("\r", "")
return "\"${escapedJson}\""
}
android {
println("Current VERSION_MAJOR: ${VERSION_MAJOR}")
println("Current VERSION_MINOR: ${VERSION_MINOR}")
println("Current VERSION_PATCH: ${VERSION_PATCH}")
println("Current VERSION_BUILD: ${VERSION_BUILD}")
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId 'de.rki.coronawarnapp'
minSdkVersion 23
targetSdkVersion 29
ndkVersion "21.2.6472646"
versionCode(
VERSION_MAJOR.toInteger() * 1000000
+ VERSION_MINOR.toInteger() * 10000
+ VERSION_PATCH.toInteger() * 100
+ VERSION_BUILD.toInteger()
)
println("Used versionCode: $versionCode")
versionName "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
println("Used versionName: $versionName")
testInstrumentationRunner "testhelpers.TestApplicationUIRunner"
resConfigs "de", "en", "tr", "bg", "pl", "ro"
def prodEnvJson = environmentExtractor(file("../prod_environments.json"))
buildConfigField "String", "ENVIRONMENT_JSONDATA", prodEnvJson
if (project.hasProperty("commit_hash")) {
buildConfigField "String", "GIT_COMMIT_SHORT_HASH", "\"$commit_hash\""
} else {
buildConfigField "String", "GIT_COMMIT_SHORT_HASH", "\"no commit hash\""
}
def devEnvironmentFile = file("../test_environments.json")
if (devEnvironmentFile.exists()) {
def devEnvJson = environmentExtractor(devEnvironmentFile)
buildConfigField "String", "ENVIRONMENT_JSONDATA", devEnvJson
}
javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
buildConfigField "int", "VERSION_MAJOR", VERSION_MAJOR
buildConfigField "int", "VERSION_MINOR", VERSION_MINOR
buildConfigField "int", "VERSION_PATCH", VERSION_PATCH
vectorDrawables.useSupportLibrary = true
}
def signingPropFile = file("../keystore.properties")
if (signingPropFile.canRead()) {
Properties signingProps = new Properties()
signingProps.load(new FileInputStream(signingPropFile))
signingConfigs {
deviceRelease {
if (signingProps['deviceRelease.storePath'] != null) {
storeFile file(signingProps['deviceRelease.storePath'])
keyAlias signingProps['deviceRelease.keyAlias']
storePassword signingProps['deviceRelease.storePassword']
keyPassword signingProps['deviceRelease.keyPassword']
}
}
deviceForTestersRelease {
if (signingProps['deviceForTestersRelease.storePath'] != null) {
storeFile file(signingProps['deviceForTestersRelease.storePath'])
keyAlias signingProps['deviceForTestersRelease.keyAlias']
storePassword signingProps['deviceForTestersRelease.storePassword']
keyPassword signingProps['deviceForTestersRelease.keyPassword']
}
}
}
}
buildTypes {
debug {
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "version"
productFlavors {
device {
dimension "version"
resValue "string", "app_name", "Corona-Warn"
ext {
envTypeDefault = [debug: "INT", release: "PROD"]
}
if (signingPropFile.canRead()) {
signingConfig signingConfigs.deviceRelease
}
}
deviceForTesters {
// Contains test fragments
dimension "version"
resValue "string", "app_name", "CWA TEST"
applicationIdSuffix '.test'
ext {
envTypeDefault = [debug: "INT", release: "WRU-XD"]
}
if (signingPropFile.canRead()) {
signingConfig signingConfigs.deviceForTestersRelease
}
}
}
applicationVariants.all { variant ->
def flavor = variant.productFlavors[0]
def typeName = variant.buildType.name // debug/release
variant.buildConfigField "String", "ENVIRONMENT_TYPE_DEFAULT", "\"${flavor.envTypeDefault[typeName]}\""
if (flavor.name == "deviceForTesters") {
def adjustedVersionName = "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-RC${VERSION_BUILD}"
variant.outputs.each { output ->
output.versionNameOverride = adjustedVersionName
}
println("deviceForTesters adjusted versionName: $adjustedVersionName")
}
if (flavor.name != "device") {
variant.outputs.each { output ->
def apkName = "Corona-Warn-App-${output.versionNameOverride}-${flavor.name}-${variant.buildType.name}.apk"
println("Override APK Name: $apkName")
output.outputFileName = apkName
}
}
}
buildFeatures {
dataBinding true
viewBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += [
"-Xno-kotlin-nothing-value-exception",
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlinx.coroutines.FlowPreview",
"-Xuse-experimental=kotlin.time.ExperimentalTime",
"-Xopt-in=kotlin.RequiresOptIn"
]
}
}
lintOptions {
checkAllWarnings = true
// this rule is broken on 2.3.0
// see the following issue: https://issuetracker.google.com/issues/169249668
disable 'NullSafeMutableLiveData'
}
testOptions {
unitTests.all {
useJUnitPlatform()
if (project.hasProperty('testFilter')) {
List<String> props = project.getProperties().get("testFilter").split("\\s+")
props.each {
def replaced = it
.replaceFirst("^(Corona-Warn-App/src/test.*/java/)(.+)\$", "**/\$2")
.replace(".kt", ".class")
project.logger.lifecycle("testFilter File: before=$it, after=$replaced")
include(replaced)
}
}
}
unitTests {
includeAndroidResources = true
returnDefaultValues = true
}
// Using orchestration together with mockk on x86 (32bit) emulator images crashes
// Leaving this in here as reminder
// https://github.com/android/android-test/issues/352
// https://github.com/mockk/mockk/issues/466
// execution 'ANDROIDX_TEST_ORCHESTRATOR'
}
kapt {
useBuildCache true
includeCompileClasspath = false
}
dexOptions {
preDexLibraries true
}
packagingOptions {
exclude "**/module-info.class"
exclude 'NOTICE'
exclude 'LICENSE'
exclude 'CODEOWNERS'
exclude 'README.md'
exclude 'CODE_OF_CONDUCT.md'
exclude 'META-INF/AL2.0'
exclude 'META-INF/LGPL2.1'
}
sourceSets {
deviceForTesters {
kotlin {
srcDirs = ['src/deviceForTesters']
}
res {
srcDirs 'src/deviceForTesters/res', 'src/deviceForTesters/res/navigation'
}
}
device {
kotlin {
srcDirs = ['src/device']
}
}
test {
java.srcDirs += "$projectDir/src/testShared/java"
}
androidTest {
java.srcDirs += "$projectDir/src/testShared/java"
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
}
}
task jacocoTestReportDeviceRelease(type: JacocoReport, dependsOn: 'testDeviceReleaseUnitTest') {
group = "Reporting"
description = "Generate Jacoco coverage reports for the DeviceRelease build."
reports {
html.enabled = false
xml {
enabled = true
destination file("$buildDir/reports/jacoco/deviceRelease/jacoco.xml")
}
}
def excludes = [
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*',
'**/*$$*',
]
def classPaths = [
"**/intermediates/classes/deviceRelease/**",
"**/intermediates/javac/deviceRelease/*/classes/**", // Android Gradle Plugin 3.2.x support.
"**/intermediates/javac/deviceRelease/classes/**", // Android Gradle Plugin 3.4 and 3.5 support.
"**/tmp/kotlin-classes/deviceRelease/**"
]
def debugTree = fileTree(dir: "$buildDir", includes: classPaths, excludes: excludes)
def mainSrc = "src/main/java"
getSourceDirectories().from(files([mainSrc]))
getClassDirectories().from(files([debugTree]))
getExecutionData().from(fileTree(dir: "$buildDir", includes: ["jacoco/testDeviceReleaseUnitTest.exec"]))
}
configurations.all {
resolutionStrategy {
force "androidx.test:monitor:1.3.0"
}
}
dependencies {
// KOTLIN
def coroutineVersion = "1.4.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutineVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutineVersion"
testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.4.21"
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutineVersion"
// ANDROID STANDARD
def nav_version = "2.3.3"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.work:work-runtime-ktx:2.5.0'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.3.1'
implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.recyclerview:recyclerview-selection:1.1.0"
// DAGGER
def dagger_version = "2.31.2"
implementation "com.google.dagger:dagger:$dagger_version"
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
kaptTest "com.google.dagger:dagger-compiler:$dagger_version"
kaptAndroidTest "com.google.dagger:dagger-compiler:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
kaptTest "com.google.dagger:dagger-android-processor:$dagger_version"
kaptAndroidTest "com.google.dagger:dagger-android-processor:$dagger_version"
// QR
implementation('com.journeyapps:zxing-android-embedded:4.1.0') { transitive = false }
// noinspection GradleDependency - needed for SDK 23 compatibility, in combination with com.journeyapps:zxing-android-embedded:4.1.0
implementation 'com.google.zxing:core:3.3.0'
//ENA
implementation files('libs/play-services-nearby-exposurenotification-18.0.3.aar')
// Testing
testImplementation "androidx.arch.core:core-testing:2.1.0"
testImplementation('org.robolectric:robolectric:4.4') {
exclude group: 'com.google.protobuf'
}
testImplementation "io.mockk:mockk:1.10.4"
testImplementation "com.squareup.okhttp3:mockwebserver:4.9.0"
testImplementation 'org.hamcrest:hamcrest-library:2.2'
// Testing - jUnit4
testImplementation 'junit:junit:4.13.1'
testImplementation "org.junit.vintage:junit-vintage-engine:5.7.0"
testImplementation "androidx.test:core-ktx:1.3.0"
// Testing - jUnit5
def jupiter_version = "5.7.0"
testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiter_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiter_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$jupiter_version"
def kotest_version = "4.3.2"
testImplementation "io.kotest:kotest-runner-junit5:$kotest_version"
testImplementation "io.kotest:kotest-assertions-core-jvm:$kotest_version"
testImplementation "io.kotest:kotest-property-jvm:$kotest_version"
androidTestImplementation "io.kotest:kotest-assertions-core-jvm:$kotest_version"
androidTestImplementation "io.kotest:kotest-property-jvm:$kotest_version"
testImplementation "io.github.classgraph:classgraph:4.8.90"
// Testing - Instrumentation
androidTestImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:truth:1.3.0'
androidTestImplementation 'androidx.work:work-testing:2.5.0'
androidTestImplementation "io.mockk:mockk-android:1.10.4"
debugImplementation 'androidx.fragment:fragment-testing:1.2.5'
debugImplementation 'androidx.test:core-ktx:1.3.0'
androidTestImplementation 'tools.fastlane:screengrab:2.0.0'
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
// Play Services
implementation 'com.google.android.play:core:1.9.0'
implementation 'com.google.android.gms:play-services-base:17.5.0'
implementation 'com.google.android.gms:play-services-basement:17.5.0'
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.google.android.gms:play-services-tasks:17.2.0'
// HTTP
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation('com.squareup.retrofit2:converter-protobuf:2.9.0') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
implementation("com.squareup.okhttp3:logging-interceptor:4.9.0")
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
// PERSISTENCE
def room_version = "2.2.6"
implementation "androidx.sqlite:sqlite-ktx:2.1.0"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-guava:$room_version"
kapt "androidx.room:room-compiler:$room_version"
androidTestImplementation "androidx.room:room-testing:$room_version"
// UTILS
implementation project(":Server-Protocol-Buffer")
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.guava:guava:30.0-android'
implementation 'joda-time:joda-time:2.10.6'
// SECURITY
implementation "androidx.security:security-crypto:1.0.0-rc03"
implementation 'net.zetetic:android-database-sqlcipher:4.4.0'
implementation 'org.conscrypt:conscrypt-android:2.5.1'
// LOGGING
implementation 'com.jakewharton.timber:timber:4.7.1@aar'
// ANIMATIONS
implementation "com.airbnb.android:lottie:3.5.0"
}