-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathbuild.gradle
More file actions
386 lines (336 loc) · 12.3 KB
/
build.gradle
File metadata and controls
386 lines (336 loc) · 12.3 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
/*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlinx-serialization'
apply plugin: 'com.google.dagger.hilt.android'
apply plugin: 'com.google.devtools.ksp'
apply plugin: 'androidx.room'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: 'com.google.protobuf'
apply plugin: 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
apply from: '../config/checkstyle/checkstyle.gradle'
apply from: '../config/lint/lint.gradle'
apply from: '../config/jacoco/jacoco.gradle'
// Directory where downloaded Protocol Buffer definitions are extracted to.
def extractedGroundProtoPath = layout.buildDirectory.dir('extracted-ground-protos')
// Gets the total number of commits
static def getGitCommitCount() {
return 'git rev-list --count HEAD'.execute().text.trim().toInteger()
}
// Gets the current git branch name and sanitizes it
static def getGitBranchName() {
def branch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
if (branch && branch != "HEAD") {
return branch.replace('/', '-') // Replaces 'feature/login' with 'feature-login'
} else {
return "detached-head" // Fallback
}
}
// Gets the short 7-character hash
static def getGitHash() {
return 'git rev-parse --short HEAD'.execute().text.trim()
}
android {
compileSdk rootProject.androidCompileSdk
sourceSets {
main {
proto {
srcDir extractedGroundProtoPath
}
assets {
srcDirs 'src/main/assets'
}
}
test {
proto {
srcDir 'src/test/proto'
}
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
}
defaultConfig {
applicationId "org.groundplatform.android"
minSdkVersion rootProject.androidMinSdk
targetSdkVersion rootProject.androidTargetSdk
versionCode getGitCommitCount()
versionName "${getGitBranchName()}-${getGitHash()}-debug"
multiDexEnabled = true
// For rendering vector map markers.
vectorDrawables.useSupportLibrary = true
buildConfigField "String", "EMULATOR_HOST", "\"10.0.2.2\""
buildConfigField "int", "FIRESTORE_EMULATOR_PORT", "8080"
buildConfigField "int", "AUTH_EMULATOR_PORT", "9099"
buildConfigField "String", "SIGNUP_FORM_LINK", "\"\""
manifestPlaceholders.usesCleartextTraffic = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
// Use flag -PtestBuildType with desired variant to change default behavior.
testBuildType = project.getProperties().getOrDefault("testBuildType", "debug")
// gradle doesn't sign debug test apk (needed for running instrumentation tests on firebase)
// https://stackoverflow.com/questions/3082780/java-lang-securityexception-permission-denial/38202106
signingConfigs {
staging {
keyPassword 'ground'
storeFile file('../cloud-builder/sign/keystore')
storePassword 'ground'
keyAlias 'ground'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
ext.enableCrashlytics = false
ext.alwaysUpdateBuildId = false
FirebasePerformance {
instrumentationEnabled = false
}
}
staging {
ext.enableCrashlytics = false
ext.alwaysUpdateBuildId = false
signingConfig = signingConfigs.staging
FirebasePerformance {
instrumentationEnabled = false
}
}
}
flavorDimensions "backend"
productFlavors {
local {
dimension "backend"
versionNameSuffix "-local"
buildConfigField "boolean", "USE_EMULATORS", "true"
manifestPlaceholders.usesCleartextTraffic = true
}
dev {
dimension "backend"
versionNameSuffix "-dev"
buildConfigField "boolean", "USE_EMULATORS", "false"
}
prod {
dimension "backend"
buildConfigField "boolean", "USE_EMULATORS", "false"
}
}
buildFeatures {
buildConfig = true
compose = true
dataBinding = true
viewBinding = true
}
testOptions {
unitTests {
includeAndroidResources = true
all {
jvmArgs '-Xmx4g' // '-XX:+HeapDumpOnOutOfMemoryError'
}
}
animationsDisabled = true
}
room {
schemaDirectory("$projectDir/schemas")
}
namespace = 'org.groundplatform.android'
}
configurations {
groundProtoJar
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation libs.androidx.multidex
implementation libs.androidx.preference.ktx
// Kotlin
implementation platform(libs.kotlinx.serialization.bom)
implementation libs.kotlin.reflect
implementation libs.kotlin.stdlib
implementation libs.kotlinx.collections.immutable
implementation libs.kotlinx.serialization.json
implementation libs.kotlinx.serialization.protobuf
// Kotlin Coroutines
implementation platform(libs.kotlinx.coroutines.bom)
implementation libs.kotlinx.coroutines.android
implementation libs.kotlinx.coroutines.core
testImplementation libs.kotlinx.coroutines.test
// Android legacy support Libraries
implementation libs.androidx.appcompat
// UI Widgets
implementation libs.androidx.constraintlayout
implementation libs.material
// Jetpack Compose
implementation platform(libs.androidx.compose.bom)
androidTestImplementation platform(libs.androidx.compose.bom)
debugImplementation libs.androidx.ui.test.manifest
debugImplementation libs.androidx.ui.tooling
implementation libs.androidx.material.icons
implementation libs.androidx.material3.android
implementation libs.androidx.runtime.livedata
implementation libs.androidx.ui
implementation libs.androidx.ui.tooling.preview.android
stagingImplementation libs.androidx.ui.test.manifest
testImplementation libs.androidx.ui.test.junit4
implementation libs.androidx.navigation.compose
implementation libs.androidx.hilt.navigation.compose
// Images
implementation libs.glide
// Google Play Services
implementation libs.play.services.auth
implementation libs.play.services.location
implementation libs.play.services.maps
// Maps Utils
implementation libs.android.maps.utils
// GeoJSON Support
implementation libs.gson
// Firebase and related libraries.
implementation platform(libs.firebase.bom)
implementation libs.firebase.auth
implementation libs.firebase.analytics
implementation libs.firebase.config
implementation libs.firebase.crashlytics
implementation libs.firebase.firestore
implementation libs.firebase.functions.ktx
implementation libs.firebase.messaging
implementation libs.firebase.messaging.directboot
implementation libs.firebase.messaging.ktx
implementation libs.firebase.perf
implementation libs.firebase.storage
// Hilt
implementation libs.androidx.hilt.navigation.fragment
implementation libs.androidx.hilt.work
implementation libs.hilt.android
testImplementation libs.hilt.android.testing
androidTestImplementation libs.hilt.android.testing
ksp libs.hilt.compiler
ksp libs.hilt.android.compiler
kspTest libs.hilt.android.compiler
kspAndroidTest libs.hilt.android.compiler
// Android Arch Lifecycle
implementation libs.androidx.lifecycle.runtime.ktx
// Android Navigation
implementation libs.androidx.navigation.fragment.ktx
implementation libs.androidx.navigation.ui.ktx
// Auto-value
compileOnly libs.auto.value.annotations
ksp libs.auto.value
// Logging
implementation libs.timber
// Room
implementation libs.androidx.room.runtime
androidTestImplementation libs.androidx.room.testing
ksp libs.androidx.room.compiler
// WorkManager
implementation libs.androidx.work.runtime.ktx
testImplementation libs.androidx.work.testing
// OSS Licenses Plugin
implementation libs.play.services.oss.licenses
// Markdown Parser
implementation libs.markdown
// Testing
androidTestImplementation libs.androidx.junit
androidTestImplementation libs.androidx.runner
androidTestImplementation libs.core.testing
androidTestImplementation libs.truth
testImplementation libs.androidx.core
testImplementation libs.androidx.core.testing
testImplementation libs.androidx.navigation.testing
testImplementation libs.core.testing
testImplementation libs.json
testImplementation libs.junit
testImplementation libs.kotlin.test
testImplementation libs.robolectric
testImplementation libs.testing
testImplementation libs.turbine
testImplementation libs.truth
// Mockito
testImplementation platform(libs.mockito.bom)
androidTestImplementation platform(libs.mockito.bom)
testImplementation libs.mockito.core
testImplementation libs.mockito.inline
testImplementation libs.mockito.kotlin
testImplementation libs.mockito.android
androidTestImplementation libs.mockito.core
// Espresso
testImplementation libs.androidx.espresso.contrib
testImplementation(libs.androidx.espresso.core) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(libs.androidx.espresso.core) {
exclude group: 'com.android.support', module: 'support-annotations'
}
// Fragments
debugImplementation libs.androidx.fragment.testing.manifest
// TODO: Move protos into shared module and set correct path here.
// Issue URL: https://github.com/google/ground-android/issues/1748
api(libs.protobuf.kotlin.lite)
// Pulls protodefs from the specified commit in the ground-platform repo.
groundProtoJar libs.ground.platform
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:4.33.0"
}
generateProtoTasks {
all().each {
it.plugins {
// Generated Kotlin classes depend on these.
create("java") {
option("lite")
}
}
it.builtins {
create("kotlin") {
option("lite")
}
}
it.dependsOn extractGroundProtoJar
}
}
}
// Extracts protodefs in downloaded JAR to the build/extracted-protos dirs.
task extractGroundProtoJar(type: Copy) {
from(
// Defer resolution until after configuration phase.
provider {
configurations.groundProtoJar.collect {
zipTree(it)
}
})
into extractedGroundProtoPath
include "**/*.proto"
}
apply plugin: 'androidx.navigation.safeargs'
// This must be last to avoid dependency collisions.
// https://developers.google.com/android/guides/google-services-plugin#introduction
apply plugin: 'com.google.gms.google-services'
kotlin {
jvmToolchain rootProject.jvmToolchainVersion
}
secrets {
// Location of file containing Maps API key for this project. Should not be checked into
// version control.
propertiesFileName = "secrets.properties"
// A properties file containing default secret values. This file can be
// checked in version control.
defaultPropertiesFileName = "local.defaults.properties"
}