Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
204 lines (180 loc) · 7.29 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
204 lines (180 loc) · 7.29 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.FileInputStream
import java.util.Properties
plugins {
alias(libs.plugins.stream.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.androidx.baseline.profile)
alias(libs.plugins.firebase.crashlytics)
alias(libs.plugins.google.services)
}
apply(from = "$rootDir/scripts/detekt-compose.gradle")
android {
namespace = "io.getstream.chat.android.compose.sample"
defaultConfig {
targetSdk = libs.versions.sampleTargetSdk.get().toInt()
applicationId = "io.getstream.chat.android.compose.sample"
versionCode = rootProject.extra.get("sampleAppVersionCode") as Int
versionName = rootProject.extra.get("sampleAppVersionName") as String
testInstrumentationRunner = "io.qameta.allure.android.runners.AllureAndroidJUnitRunner"
testInstrumentationRunnerArguments["clearPackageData"] = "true"
}
testOptions {
execution = "ANDROIDX_TEST_ORCHESTRATOR"
}
val signFile = rootProject.file(".sign/keystore.properties")
if (signFile.exists()) {
val properties = Properties()
properties.load(FileInputStream(signFile))
signingConfigs {
create("release") {
keyAlias = properties["keyAlias"] as? String
keyPassword = properties["keyPassword"] as? String
storeFile = rootProject.file(properties["keystore"] as String)
storePassword = properties["storePassword"] as? String
}
}
} else {
signingConfigs {
create("release") {
keyAlias = "androiddebugkey"
keyPassword = "android"
storeFile = rootProject.file(".sign/debug.keystore")
storePassword = "android"
}
}
}
signingConfigs {
getByName("debug") {
keyAlias = "androiddebugkey"
keyPassword = "android"
storeFile = rootProject.file(".sign/debug.keystore")
storePassword = "android"
}
}
val e2eCoverage = providers.gradleProperty("e2eCoverage").isPresent
buildTypes {
getByName("debug") {
versionNameSuffix = "-DEBUG"
applicationIdSuffix = ".debug"
// The e2e run on CI passes -Pe2eNonDebuggable: a debuggable app runs much slower on the emulators.
// The coverage build stays debuggable.
isDebuggable = !providers.gradleProperty("e2eNonDebuggable").isPresent || e2eCoverage
isMinifyEnabled = false
isShrinkResources = false
// The nightly e2e run instruments the app and the SDK to map the code every test runs.
enableAndroidTestCoverage = e2eCoverage
signingConfig = signingConfigs.getByName("debug")
buildConfigField("Boolean", "BENCHMARK", "false")
}
create("benchmark") {
isDebuggable = false
signingConfig = signingConfigs.getByName("debug")
matchingFallbacks += listOf("release")
proguardFiles("benchmark-rules.pro")
buildConfigField("Boolean", "BENCHMARK", "true")
}
getByName("release") {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
signingConfig = signingConfigs.getByName("release")
buildConfigField("Boolean", "BENCHMARK", "false")
}
}
flavorDimensions += "version"
productFlavors {
create("demo") {
dimension = "version"
buildConfigField("Boolean", "STRICT_MODE", "true")
}
create("e2e") {
dimension = "version"
applicationIdSuffix = ".e2etest"
// StrictMode slows the e2e run down, and nobody reads its logs there.
buildConfigField("Boolean", "STRICT_MODE", "false")
}
}
buildFeatures {
compose = true
buildConfig = true
}
lint {
disable += "MissingTranslation"
}
}
androidComponents {
beforeVariants { variantBuilder ->
// The e2e flavor only builds debug. A non-debuggable debug gets benchmarkDebug and nonMinifiedDebug variants
// from the baseline profile plugin, which fails the configuration when they are disabled.
val buildType = variantBuilder.buildType.orEmpty()
if (buildType != "debug" && !buildType.endsWith("Debug") &&
variantBuilder.productFlavors.any { it.second.contains("e2e") }
) {
variantBuilder.enable = false
}
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
compilerOptions.freeCompilerArgs.addAll(
listOf(
"-opt-in=kotlin.RequiresOptIn",
),
)
}
dependencies {
implementation(project(":stream-chat-android-compose"))
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.appcompat)
implementation(libs.android.material)
implementation(libs.stream.log)
// Compose
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.material.icons.core)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.google.accompanist.permissions)
implementation(libs.coil.compose)
implementation(libs.play.services.location)
// Firebase - both flavors need it for compilation
// demo: real Firebase with actual push notifications
// e2e: fake google-services.json, Firebase present but not actively used
implementation(libs.stream.push.firebase)
implementation(libs.firebase.analytics.ktx)
implementation(libs.firebase.crashlytics)
// Unit tests
testImplementation(project(":stream-chat-android-test"))
testImplementation(testFixtures(project(":stream-chat-android-core")))
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
testImplementation(libs.kluent)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.turbine)
// Instrumentation tests
"e2eImplementation"(libs.okhttp)
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.androidx.test.uiautomator)
androidTestImplementation(libs.androidx.test.junit.ktx)
androidTestImplementation(libs.androidx.test.monitor)
androidTestUtil(libs.androidx.test.orchestrator)
androidTestImplementation(libs.allure.kotlin.model)
androidTestImplementation(libs.allure.kotlin.junit4)
androidTestImplementation(libs.allure.kotlin.commons)
androidTestImplementation(libs.allure.kotlin.android)
androidTestImplementation(project(":stream-chat-android-e2e-test"))
detektPlugins(libs.detekt.formatting)
baselineProfile(project(":stream-chat-android-benchmark"))
}