-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
526 lines (462 loc) · 18.4 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
526 lines (462 loc) · 18.4 KB
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
/*
* © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
* Contributors: denbond7
*/
import com.android.ddmlib.DdmPreferences
import java.io.FileInputStream
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Properties
//Setting global timeout for apk installation to 10 minutes. We need it for CI
DdmPreferences.setTimeOut(10 * 60 * 1000)
plugins {
id("com.android.application")
id("kotlin-android")
id("androidx.navigation.safeargs.kotlin")
id("com.starter.easylauncher")
id("kotlin-parcelize")
id("com.google.devtools.ksp")
id("org.ajoberstar.grgit")
}
val keystoreProperties = Properties()
val propertiesFile = project.file("keystore.properties")
if (propertiesFile.exists()) {
keystoreProperties.load(FileInputStream(propertiesFile))
}
android {
compileSdk = extra["compileSdkVersion"] as Int
namespace = "com.flowcrypt.email"
defaultConfig {
/*
The following argument makes the Android Test Orchestrator run its
"pm clear" command after each test invocation. This command ensures
that the app"s state is completely cleared between tests.
*/
testInstrumentationRunnerArguments += mapOf("clearPackageData" to "true")
applicationId = "com.flowcrypt.email"
minSdk = extra["minSdkVersion"] as Int
targetSdk = extra["targetSdkVersion"] as Int
versionCode = extra["appVersionCode"] as Int
versionName = extra["appVersionName"] as String
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("int", "MIN_SDK_VERSION", "$minSdk")
multiDexEnabled = true
}
signingConfigs {
create("release") {
var keyStoreFile = keystoreProperties["storeFile"]?.toString()
var keyStorePass = keystoreProperties["storePassword"]?.toString()
var keySignAlias = keystoreProperties["keyAlias"]?.toString()
var keyPass = keystoreProperties["keyPassword"]?.toString()
if (project.hasProperty("runtimeSign")) {
if (project.hasProperty("storeFile")) {
keyStoreFile = project.property("storeFile") as? String
}
if (project.hasProperty("storePassword")) {
keyStorePass = project.property("storePassword") as? String
}
if (project.hasProperty("keyAlias")) {
keySignAlias = project.property("keyAlias") as? String
}
if (project.hasProperty("keyPassword")) {
keyPass = project.property("keyPassword") as? String
}
}
storeFile = file(keyStoreFile ?: "Store file is not defined")
storePassword = keyStorePass
keyAlias = keySignAlias
keyPassword = keyPass
}
getByName("debug") {
storeFile = file("debug.keystore")
storePassword = "android"
keyAlias = "flowcryptdebugkey"
keyPassword = "android"
}
}
buildTypes {
getByName("release") {
isShrinkResources = false
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
signingConfig = signingConfigs.getByName("release")
}
getByName("debug") {
isDebuggable = true
versionNameSuffix = "_" +
defaultConfig.versionCode +
"__" + SimpleDateFormat("yyyy_MM_dd").format(Date()) +
"__" + grgit.head().id.substring(0, 7)
applicationIdSuffix = ".debug"
signingConfig = signingConfigs.getByName("debug")
buildConfigField("boolean", "IS_ACRA_ENABLED", "false")
buildConfigField("boolean", "IS_HTTP_LOG_ENABLED", "true")
buildConfigField("String", "HTTP_LOG_LEVEL", "\"BODY\"")
resValue("string", "gradle_is_acra_enabled", "false")
resValue("string", "gradle_is_http_log_enabled", "true")
resValue("string", "gradle_http_log_level", "BODY")
}
create("uiTests") {
initWith(getByName("debug"))
versionNameSuffix =
"_test_" + defaultConfig.versionCode + "__" + SimpleDateFormat("yyyy_MM_dd").format(Date())
buildConfigField("String", "ATTESTER_URL", "\"https://flowcrypt.test/attester/\"")
buildConfigField(
"String",
"SHARED_TENANT_FES_URL",
"\"https://flowcrypt.test/shared-tenant-fes/\""
)
buildConfigField("boolean", "IS_HTTP_LOG_ENABLED", "false")
buildConfigField("String", "HTTP_LOG_LEVEL", "\"NONE\"")
resValue("string", "gradle_is_http_log_enabled", "false")
resValue("string", "gradle_http_log_level", "NONE")
}
}
testBuildType = "uiTests"
sourceSets {
getByName("androidTest").assets.srcDir("$projectDir/schemas")
}
flavorDimensions += "standard"
productFlavors {
//This is a consumer flavor. It's a base flavor
create("consumer") {
dimension = "standard"
buildConfigField("boolean", "IS_ACRA_ENABLED", "true")
buildConfigField("boolean", "IS_MAIL_DEBUG_ENABLED", "false")
buildConfigField("boolean", "IS_HTTP_LOG_ENABLED", "false")
buildConfigField("String", "HTTP_LOG_LEVEL", "\"NONE\"")
buildConfigField("String", "ATTESTER_URL", "\"https://flowcrypt.com/attester/\"")
buildConfigField(
"String",
"SHARED_TENANT_FES_URL",
"\"https://flowcrypt.com/shared-tenant-fes/\""
)
resValue("string", "gradle_is_acra_enabled", "true")
resValue("string", "gradle_is_mail_debug_enabled", "false")
resValue("string", "gradle_is_http_log_enabled", "false")
resValue("string", "gradle_http_log_level", "NONE")
}
//This is an enterprise flavor
create("enterprise") {
initWith(getByName("consumer"))
dimension = "standard"
applicationIdSuffix = ".enterprise"
//https://github.com/FlowCrypt/flowcrypt-android/issues/2174
buildConfigField("boolean", "IS_ACRA_ENABLED", "false")
resValue("string", "gradle_is_acra_enabled", "false")
}
//This flavor must be used only for a development.
//It has settings for a fast building (some features are disabled or not included).
create("dev") {
initWith(getByName("consumer"))
dimension = "standard"
versionNameSuffix = "_dev"
buildConfigField("boolean", "IS_MAIL_DEBUG_ENABLED", "true")
resValue("string", "gradle_is_mail_debug_enabled", "true")
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
buildFeatures {
buildConfig = true
viewBinding = true
}
packaging {
resources.excludes += setOf(
"META-INF/DEPENDENCIES",
"META-INF/LICENSE.md",
"META-INF/NOTICE.md",
"META-INF/INDEX.LIST",
"META-INF/*.SF",
"META-INF/*.DSA",
"META-INF/*.RSA",
"META-INF/javamail.providers",
"META-INF/versions/9/OSGI-INF/MANIFEST.MF",
)
}
lint {
warningsAsErrors = true
//we have to disable lint for 'GradleDependency' checks as we use dependabot for dependencies
disable += "GradleDependency"
}
testOptions {
animationsDisabled = true
execution = "ANDROIDX_TEST_ORCHESTRATOR"
unitTests.all {
it.testLogging {
events = setOf(
org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED,
org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED,
org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED,
org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_ERROR
)
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showStandardStreams = true
showCauses = true
showExceptions = true
showStackTraces = true
}
it.addTestListener(object : TestListener {
override fun beforeSuite(suite: TestDescriptor) {}
override fun beforeTest(testDescriptor: TestDescriptor) {}
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {
}
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
if (suite.parent == null) {
logger.lifecycle("----")
logger.lifecycle("Test result: ${result.resultType}")
logger.lifecycle(
"Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"
)
}
}
})
}
}
}
ksp {
//used by Room, to test migrations
arg("room.schemaLocation", "$projectDir/schemas")
}
androidComponents {
beforeVariants { variantBuilder ->
if (variantBuilder.name in listOf("devRelease", "devUiTests")) {
// Gradle ignores any variants that satisfy the conditions above.
println("INFO: Excluded \"${variantBuilder.name}\" from build variant list as unused")
variantBuilder.enable = false
}
}
onVariants { variant ->
//we share applicationId as a res value
variant.resValues.put(
variant.makeResValueKey("string", "application_id"),
com.android.build.api.variant.ResValue(variant.applicationId.get())
)
}
}
easylauncher {
buildTypes {
register("debug") {
filters(
chromeLike(
ribbonColor = "#6600CC",
labelColor = "#FFFFFF",
gravity = com.project.starter.easylauncher.filter.ChromeLikeFilter.Gravity.BOTTOM,
overlayHeight = 0.25f,
textSizeRatio = 0.2f,
)
)
}
register("uiTests") {
filters(
chromeLike(
label = "test",
ribbonColor = "#E91E63",
labelColor = "#FFFFFF",
gravity = com.project.starter.easylauncher.filter.ChromeLikeFilter.Gravity.BOTTOM,
overlayHeight = 0.25f,
textSizeRatio = 0.2f,
)
)
}
}
variants {
register("devDebug") {
filters(
chromeLike(
label = "dev",
ribbonColor = "#CC5F00",
labelColor = "#FFFFFF",
gravity = com.project.starter.easylauncher.filter.ChromeLikeFilter.Gravity.BOTTOM,
overlayHeight = 0.25f,
textSizeRatio = 0.2f,
)
)
}
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}
tasks.register("checkCorrectBranch") {
if (!grgit.branch.current().name.equals("master")) {
throw GradleException("Please use 'master' branch to generate a release build")
}
}
tasks.register("checkReleaseBuildsSize") {
doLast {
android.applicationVariants.forEach { applicationVariant ->
if (applicationVariant.buildType.name == "release") {
applicationVariant.outputs.forEach { variantOutput ->
val apkFile = variantOutput.outputFile
//for now apk up to 50Mb is normal
val maxExpectedSizeInBytes = 50 * 1024 * 1024
if (apkFile.length() > maxExpectedSizeInBytes) {
throw GradleException(
"The generated release build is bigger then expected: " +
"expected = not big then $maxExpectedSizeInBytes, actual = ${apkFile.length()}"
)
}
}
}
}
}
}
tasks.register("renameReleaseBuilds") {
doLast {
android.applicationVariants.forEach { applicationVariant ->
if (applicationVariant.buildType.name == "release") {
applicationVariant.outputs.forEach { variantOutput ->
val file = variantOutput.outputFile
val newName = file.name.replace(
".apk", "_" + android.defaultConfig.versionCode +
"_" + android.defaultConfig.versionName + "_"
+ SimpleDateFormat("yyyy_MM_dd_HH_mm").format(Date()) + ".apk"
)
variantOutput.outputFile.renameTo(File(file.parent, newName))
}
}
}
}
}
tasks.register<Copy>("copyReleaseApks") {
includeEmptyDirs = false
into(
File(rootProject.rootDir, "release").apply {
if (!exists() && !mkdirs()) {
error("Can't create $name")
}
}
)
with(
copySpec {
from(layout.buildDirectory)
include("**/*release*.apk")
}
)
eachFile {
//replace path to copy only apk file to the destination folder(without subdirectories)
path = file.name
}
}
val devDebugImplementation: Configuration by configurations.creating
val uiTestsImplementation by configurations.named("uiTestsImplementation")
dependencies {
ksp("com.github.bumptech.glide:ksp:5.0.4")
ksp("androidx.annotation:annotation:1.9.1")
ksp("androidx.room:room-compiler:2.7.2")
//ACRA needs the following dependency to use a custom report sender
ksp("dev.zacsweers.autoservice:auto-service-ksp:1.2.0")
ksp("com.google.auto.service:auto-service:1.1.1")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
devDebugImplementation("com.squareup.leakcanary:leakcanary-android:2.14")
//uiTests is the build type for testing.
//noinspection FragmentGradleConfiguration
uiTestsImplementation("androidx.fragment:fragment-testing:1.8.9")
uiTestsImplementation("androidx.test:core-ktx:1.7.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.7.0")
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.7.0")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.7.0")
androidTestImplementation("androidx.test.espresso:espresso-web:3.7.0")
androidTestImplementation("androidx.test.ext:junit:1.3.0")
androidTestImplementation("androidx.test:runner:1.7.0")
androidTestImplementation("androidx.test:rules:1.7.0")
androidTestImplementation("androidx.test.ext:junit-ktx:1.3.0")
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0")
androidTestImplementation("androidx.room:room-testing:2.7.2")
androidTestImplementation("androidx.arch.core:core-testing:2.2.0")
androidTestImplementation("androidx.work:work-testing:2.10.3")
androidTestImplementation("com.squareup.okhttp3:mockwebserver:5.1.0")
androidTestImplementation("com.squareup.okhttp3:okhttp-tls:5.1.0")
androidTestImplementation("com.athaydes.rawhttp:rawhttp-core:2.6.0")
androidTestUtil("androidx.test:orchestrator:1.6.1")
testImplementation("com.squareup.okhttp3:mockwebserver:5.1.0")
testImplementation("com.flextrade.jfixture:jfixture:2.7.2")
testImplementation("com.shazam:shazamcrest:0.11")
testImplementation("org.robolectric:robolectric:4.16")
//we need it to test Parcelable implementation
testImplementation("org.jetbrains.kotlin:kotlin-reflect:2.2.10")
testImplementation("junit:junit:4.13.2")
testImplementation("androidx.room:room-testing:2.7.2")
testImplementation("io.github.classgraph:classgraph:4.8.181")
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.appcompat:appcompat:1.7.1")
implementation("androidx.legacy:legacy-preference-v14:1.0.0")
implementation("androidx.cardview:cardview:1.0.0")
implementation("androidx.browser:browser:1.9.0")
implementation("androidx.recyclerview:recyclerview:1.4.0")
implementation("androidx.recyclerview:recyclerview-selection:1.2.0")
implementation("androidx.constraintlayout:constraintlayout:2.2.1")
implementation("androidx.test.espresso:espresso-idling-resource:3.7.0")
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.3")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.9.3")
implementation("androidx.lifecycle:lifecycle-process:2.9.3")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.9.3")
implementation("androidx.lifecycle:lifecycle-service:2.9.3")
implementation("androidx.room:room-runtime:2.7.2")
implementation("androidx.room:room-ktx:2.7.2")
//we disabled warnings about paging-runtime-ktx because a newer version doesn't fit our needs
//noinspection GradleDependency
implementation("androidx.paging:paging-runtime-ktx:2.1.2")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.core:core-ktx:1.17.0")
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.activity:activity-ktx:1.11.0")
implementation("androidx.fragment:fragment-ktx:1.8.9")
implementation("androidx.work:work-runtime-ktx:2.10.3")
implementation("androidx.navigation:navigation-fragment-ktx:2.9.3")
implementation("androidx.navigation:navigation-ui-ktx:2.9.3")
implementation("androidx.navigation:navigation-runtime-ktx:2.9.3")
implementation("androidx.webkit:webkit:1.14.0")
implementation("com.google.android.gms:play-services-base:18.7.2")
implementation("com.google.android.gms:play-services-auth:21.4.0")
implementation("com.google.android.material:material:1.12.0")
implementation("com.google.android.flexbox:flexbox:3.0.0")
implementation("com.google.code.gson:gson:2.13.1")
implementation("com.google.api-client:google-api-client-android:2.8.1")
implementation("com.google.apis:google-api-services-gmail:v1-rev20250630-2.0.0")
//ACRA needs the following dependency to use a custom report sender
implementation("com.google.auto.service:auto-service-annotations:1.1.1")
implementation("com.squareup.retrofit2:retrofit:3.0.0")
implementation("com.squareup.retrofit2:converter-gson:3.0.0")
implementation("com.squareup.retrofit2:converter-scalars:3.0.0")
implementation("com.squareup.okio:okio:3.16.0")
implementation("com.squareup.okhttp3:logging-interceptor:5.1.0")
implementation("com.github.bumptech.glide:glide:5.0.4")
implementation("com.nulab-inc:zxcvbn:1.9.0")
implementation("com.burhanrashid52:photoeditor:3.0.2")
implementation("com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20240325.1")
implementation("com.sandinh:zbase32-commons-codec_2.12:1.0.0")
implementation("org.bitbucket.b_c:jose4j:0.9.6")
implementation("org.jsoup:jsoup:1.21.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
implementation("org.pgpainless:pgpainless-core:1.7.6")
implementation("org.eclipse.angus:angus-mail:2.0.4")
implementation("org.eclipse.angus:gimap:2.0.4")
implementation("commons-io:commons-io:2.20.0")
implementation("net.openid:appauth:0.11.1")
implementation("ch.acra:acra-http:5.12.0")
implementation("io.github.everythingme:overscroll-decor-android:1.1.1")
constraints {
//due to https://github.com/FlowCrypt/flowcrypt-security/issues/199
implementation("commons-codec:commons-codec:1.19.0") {
because("version 1.11 has VULNERABILITY DESCRIPTION CWE-200")
}
}
}