-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsettings.gradle.kts
More file actions
421 lines (393 loc) · 17.3 KB
/
Copy pathsettings.gradle.kts
File metadata and controls
421 lines (393 loc) · 17.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
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
import org.gradle.api.initialization.ProjectDescriptor
pluginManagement {
includeBuild("build-logic")
repositories {
mavenLocal()
google()
mavenCentral()
gradlePluginPortal()
maven(url = "https://jitpack.io") {
content {
includeGroupByRegex("com\\.github\\..*")
includeGroupByRegex("com\\.gitlab\\..*")
includeGroupByRegex("com\\.bitbucket\\..*")
}
}
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "dagger.hilt.android.plugin") {
useModule("com.google.dagger:hilt-android-gradle-plugin:${requested.version}")
}
}
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}
// The contract packages are consumed at the versions pinned in gradle/libs.versions.toml,
// which means trying a proto change would mean publishing one. Point protoLocalRoot at the
// directory holding ocp-client-protocol/ and flipcash2-client-protocol/ to build against
// those checkouts instead:
//
// # local.properties
// protoLocalRoot=/Users/you/dev/bmcreations/code
//
// Gradle substitutes com.flipcash:ocp-client-protocol and com.flipcash:flipcash2-client-protocol
// for the included builds on its own, because the coordinates match. The version in
// libs.versions.toml is ignored while this is on.
//
// local.properties is untracked and CI never writes it, so release builds always resolve the
// pinned versions from Maven Central.
//
// protoLocalPackages picks which package(s) to substitute, e.g. protoLocalPackages=flipcash2
// (comma-separated, ocp/flipcash2 or the full directory names, case-insensitive), and is
// required whenever protoLocalRoot is set — there's no "both" default. A contract sync touches
// one package at a time, so defaulting to "both" would feed the build whatever unrelated
// in-progress state the other package's checkout happens to be on. Use
// protoLocalPackages=ocp,flipcash2 to select both explicitly.
val localProperties = java.util.Properties().apply {
val f = File(settingsDir, "local.properties")
if (f.exists()) f.inputStream().use { load(it) }
}
val protoLocalRoot = localProperties.getProperty("protoLocalRoot")?.trim()?.takeIf { it.isNotEmpty() }
if (protoLocalRoot != null) {
val repoAliases = linkedMapOf(
"ocp-client-protocol" to setOf("ocp", "ocp-client-protocol"),
"flipcash2-client-protocol" to setOf("flipcash2", "flipcash2-client-protocol"),
)
val requestedPackages = localProperties.getProperty("protoLocalPackages")
?.split(",")
?.map { it.trim() }
?.filter { it.isNotEmpty() }
?.takeIf { it.isNotEmpty() }
?: throw GradleException(
"protoLocalRoot is set but protoLocalPackages is missing. Add it to local.properties, " +
"e.g. protoLocalPackages=ocp,flipcash2. Valid values (comma-separated): ocp, " +
"flipcash2, ocp-client-protocol, flipcash2-client-protocol."
)
val selectedRepos = requestedPackages.map { token ->
repoAliases.entries.firstOrNull { (_, aliases) -> aliases.any { it.equals(token, ignoreCase = true) } }?.key
?: throw GradleException(
"protoLocalPackages has an unrecognised entry '$token'. Valid values: " +
"ocp, flipcash2, ocp-client-protocol, flipcash2-client-protocol."
)
}.distinct()
selectedRepos.forEach { repo ->
val dir = File(protoLocalRoot, repo)
require(dir.isDirectory) {
"protoLocalRoot=$protoLocalRoot has no $repo checkout in it"
}
includeBuild(dir)
}
logger.lifecycle("Contract packages: building $selectedRepos from $protoLocalRoot, not the pinned versions")
}
dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.PREFER_SETTINGS
repositories {
mavenLocal()
google()
mavenCentral()
maven(url = "https://plugins.gradle.org/m2/")
maven(url = "https://maven.fpregistry.io/releases")
maven(url = "https://jitpack.io") {
content {
includeGroupByRegex("com\\.github\\..*")
includeGroupByRegex("com\\.gitlab\\..*")
includeGroupByRegex("com\\.bitbucket\\..*")
}
}
maven(url = "https://central.sonatype.com/repository/maven-snapshots/")
}
}
rootProject.name = "Flipcash"
include(
// app containers
":apps:flipcash:app",
":apps:flipcash:benchmark",
// flipcash modules
":apps:flipcash:core",
":apps:flipcash:core-ui",
":apps:flipcash:card-expand",
":libs:test-utils",
// shared flipcash coordinators/controllers/viewmodels/services
":apps:flipcash:shared:amount-entry",
":apps:flipcash:shared:accesskey",
":apps:flipcash:shared:analytics",
":apps:flipcash:shared:appsettings",
":apps:flipcash:shared:authentication",
":apps:flipcash:shared:activityfeed",
":apps:flipcash:shared:transaction-history",
":apps:flipcash:shared:blocklist",
":apps:flipcash:shared:bills",
":apps:flipcash:shared:bill-customization",
":apps:flipcash:shared:chat",
":apps:flipcash:shared:chat-ui",
":apps:flipcash:shared:common-ui",
":apps:flipcash:shared:contacts",
":apps:flipcash:shared:currency-creator",
":apps:flipcash:shared:payments",
":apps:flipcash:shared:onramp:coinbase",
":apps:flipcash:shared:onramp:deeplinks",
":apps:flipcash:shared:appupdates",
":apps:flipcash:shared:google-play-billing",
":apps:flipcash:shared:region-selection:core",
":apps:flipcash:shared:region-selection:ui",
":apps:flipcash:shared:featureflags",
":apps:flipcash:shared:ksp",
":apps:flipcash:shared:menu",
":apps:flipcash:shared:notifications",
":apps:flipcash:shared:funding",
":apps:flipcash:shared:permissions",
":apps:flipcash:shared:push",
":apps:flipcash:shared:persistence:db",
":apps:flipcash:shared:persistence:provider",
":apps:flipcash:shared:persistence:sources",
":apps:flipcash:shared:phone",
":apps:flipcash:shared:router",
":apps:flipcash:shared:session",
":apps:flipcash:shared:shareable",
":apps:flipcash:shared:invite",
":apps:flipcash:shared:tokens",
":apps:flipcash:shared:tokens:core",
":apps:flipcash:shared:theme",
":apps:flipcash:shared:profile",
":apps:flipcash:shared:blob",
":apps:flipcash:shared:tipping",
":apps:flipcash:shared:userflags",
":apps:flipcash:shared:workers",
":apps:flipcash:shared:web",
// flipcash features
":apps:flipcash:features:login",
":apps:flipcash:features:scanner",
":apps:flipcash:features:cash",
":apps:flipcash:features:balance",
":apps:flipcash:features:menu",
":apps:flipcash:features:purchase",
":apps:flipcash:features:lab",
":apps:flipcash:features:appupdates",
":apps:flipcash:features:deposit",
":apps:flipcash:features:advanced",
":apps:flipcash:features:currency-creator",
":apps:flipcash:features:messenger",
":apps:flipcash:features:invite",
":apps:flipcash:features:device-logs",
":apps:flipcash:features:myaccount",
":apps:flipcash:features:backupkey",
":apps:flipcash:features:shareapp",
":apps:flipcash:features:withdrawal",
":apps:flipcash:features:contact-verification",
":apps:flipcash:features:tokens",
":apps:flipcash:features:transactions",
":apps:flipcash:features:bill-customization",
":apps:flipcash:features:discovery",
":apps:flipcash:features:user-profile",
":apps:flipcash:features:userflags",
":apps:flipcash:features:tipping",
// Internal libs
":libs:analytics-events",
":libs:biometrics",
":libs:code-detection",
":libs:codes:kikcode",
":libs:coroutines",
":libs:crypto:kin",
":libs:crypto:solana",
":libs:currency",
":libs:currency-math",
":libs:currency-math:discrete-curve",
":libs:datetime",
":libs:emojis",
":libs:encryption:base58",
":libs:encryption:chat-cipher",
":libs:encryption:ed25519",
":libs:encryption:ed25519-native",
":libs:encryption:hmac",
":libs:encryption:keys",
":libs:encryption:mnemonic",
":libs:encryption:sha256",
":libs:encryption:sha512",
":libs:encryption:utils",
":libs:locale:bindings",
":libs:locale:impl",
":libs:locale:public",
":libs:logging",
":libs:messaging",
":libs:models",
":libs:opengraph",
":libs:network:coinbase:onramp",
":libs:network:connectivity:bindings",
":libs:network:connectivity:impl",
":libs:network:connectivity:public",
":libs:network:jwt",
":libs:permissions:bindings",
":libs:permissions:impl",
":libs:permissions:public",
":libs:quickresponse",
":libs:reporting",
":libs:search",
":libs:vibrator:bindings",
":libs:vibrator:impl",
":libs:vibrator:public",
// Services definition for app and lib access
":services:opencode",
":services:opencode-compose",
":services:flipcash",
":services:flipcash-compose",
// common UI
":ui:biometrics",
":ui:core",
":ui:components",
":ui:navigation",
":ui:resources",
":ui:scanner",
":ui:testing",
":ui:theme",
// cross-platform shared core (Kotlin Multiplatform → Android + iOS XCFramework)
":kmp:shared-core",
// 3rd party imported dependencies
":vendor:kik:scanner",
":vendor:tipkit:tipkit",
":vendor:tipkit:tipkit-m2",
)
// ---- Cross-module aggregation wiring (single source of truth) ----
// The root build script can no longer discover modules by iterating `subprojects`
// (Isolated Projects forbids it), so the module sets used for coverage and the
// aggregate unit-test task are derived here from the actual included projects and
// handed to the root project via extra properties. New modules are picked up
// automatically; only modules that break the usual conventions need to be listed
// in the small denylists below (their plugin type isn't knowable until project
// configuration, which IP forbids the root from inspecting).
// Only real modules, not the intermediate container projects that Gradle
// auto-creates for nested paths (e.g. `:apps:flipcash:shared`) — those have no
// build script and must not receive a `kover(project(...))` / test dependency.
val includedProjectPaths = buildList {
fun collect(descriptor: ProjectDescriptor) {
val hasBuildScript = descriptor.projectDir.resolve("build.gradle.kts").exists() ||
descriptor.projectDir.resolve("build.gradle").exists()
if (descriptor.path != ":" && hasBuildScript) {
add(descriptor.path)
}
descriptor.children.forEach(::collect)
}
collect(rootProject)
}
// Coverage: every module under these paths applies a `flipcash.android.*`
// convention plugin (which pulls in Kover); :apps:flipcash:app applies Kover
// directly. The denylist holds the modules under those paths that have no Kover.
val koverPaths = listOf(":apps:flipcash", ":libs", ":ui", ":services:flipcash", ":services:opencode")
val nonKoverModules = setOf(
":apps:flipcash:benchmark", // com.android.test — no Kover
":apps:flipcash:shared:ksp", // pure-JVM helper — no Kover
)
val koverModules = includedProjectPaths.filter { path ->
koverPaths.any { path == it || path.startsWith("$it:") } && path !in nonKoverModules
}
// Aggregate unit tests: :apps:flipcash, service modules, :libs (host-JVM cross-platform vector
// gates + pure-JVM lib tests), and :kmp. Android library modules expose `testDebugUnitTest`;
// KMP modules (`com.android.kotlin.multiplatform.library` + `withHostTest {}`) expose
// `testAndroidHostTest`; pure-JVM modules expose `test`; `:benchmark` is androidTest-only and the
// `:kmp:shared-core` umbrella has no tests of its own.
val unitTestPaths = listOf(":apps:flipcash", ":services:flipcash", ":services:opencode", ":libs", ":kmp")
val jvmUnitTestModules = setOf(":apps:flipcash:shared:ksp")
// KMP modules run their host tests via `testAndroidHostTest`, not `testDebugUnitTest`.
val kmpUnitTestModules = setOf(
":libs:codes:kikcode",
":libs:currency-math:discrete-curve",
":libs:encryption:base58",
":libs:encryption:sha256",
":libs:encryption:sha512",
":libs:encryption:hmac",
// ed25519's androidHostTest is a JNI vector test that needs a host-native lib
// (macOS .dylib / Linux .so); it can't load on the Linux CI runner. Its ed25519.json
// parity is gated via the iOS cinterop path (macOS) instead — so it's excluded here.
":libs:encryption:utils",
":libs:analytics-events",
":libs:reporting",
)
// ed25519 and mnemonic excluded: both pull in the JNI-backed Ed25519Kmp Android actual for their
// host vector tests, which can't load on the Linux CI runner (see kmpUnitTestModules). chat-cipher
// has no host test for the same reason, plus libsodium's Android binding; its vectors run on the
// iOS simulator in the SharedCore tests workflow and as a device test.
val noUnitTestModules = setOf(
":apps:flipcash:benchmark",
":kmp:shared-core",
":libs:encryption:chat-cipher",
":libs:encryption:ed25519",
":libs:encryption:mnemonic",
)
val unitTestCandidates = includedProjectPaths.filter { path ->
unitTestPaths.any { path == it || path.startsWith("$it:") } && path !in noUnitTestModules
}
val androidUnitTestModules = unitTestCandidates.filter {
it !in jvmUnitTestModules && it !in kmpUnitTestModules
}
// Forced dependency versions for the per-project configuration below. The
// version catalog isn't registered on projects yet at `beforeProject` time, so
// the coordinates are resolved here from the catalog's TOML (keeping them in sync
// with `gradle/libs.versions.toml`) and captured as plain strings.
val versionsToml = rootDir.resolve("gradle/libs.versions.toml").readText()
fun catalogVersion(key: String): String =
Regex("""(?m)^\s*${Regex.escape(key)}\s*=\s*"([^"]+)"""")
.find(versionsToml)?.groupValues?.get(1)
?: error("Version '$key' not found in gradle/libs.versions.toml")
val kotlinVersion = catalogVersion("kotlin")
val serializationVersion = catalogVersion("kotlinx-serialization")
// Per-project configuration that previously lived in the root build script's
// `allprojects { }` block, plus handing the aggregation lists above to the root
// project. Isolated Projects forbids a project (the root) configuring other
// projects, so this runs via the isolated `gradle.lifecycle.beforeProject` hook,
// which applies per-project setup to every project (including the root) without
// crossing project boundaries.
//
// The action is isolated (serialized), so it must not capture a reference to this
// settings script. Everything it needs is therefore copied into local `val`s in
// the block below — captured by value rather than via the script object.
run {
val koverModulesForRoot = koverModules.toList()
val androidUnitTestForRoot = androidUnitTestModules.toList()
val jvmUnitTestForRoot = jvmUnitTestModules.toList()
val kmpUnitTestForRoot = kmpUnitTestModules.toList()
val forcedDependencies = listOf(
"org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion",
"org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion",
"org.jetbrains.kotlin:kotlin-metadata-jvm:$kotlinVersion",
)
// Robolectric reaches into JDK internals that the module system closes off by
// default on Java 9+. From 4.17 it uses jdk.internal.access.SharedSecrets to set
// up FileDescriptor, which throws IllegalAccessException on our Java 21 toolchain
// unless that package is opened; the rest mirror Robolectric's own test config so
// shadows that reflect into java.nio, java.text and the AWT font stack keep working.
// This has to live here rather than in a convention plugin: :libs:encryption:utils
// runs Robolectric from androidHostTest and applies the AGP/KMP plugins directly,
// so no flipcash convention plugin sees it.
val robolectricJvmArgs = listOf(
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens=java.base/java.io=ALL-UNNAMED",
"--add-opens=java.base/java.net=ALL-UNNAMED",
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/java.security=ALL-UNNAMED",
"--add-opens=java.base/java.text=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.base/jdk.internal.access=ALL-UNNAMED",
"--add-opens=java.desktop/java.awt.font=ALL-UNNAMED",
)
gradle.lifecycle.beforeProject {
if (path == ":") {
extra["flipcash.koverModules"] = koverModulesForRoot
extra["flipcash.androidUnitTestModules"] = androidUnitTestForRoot
extra["flipcash.jvmUnitTestModules"] = jvmUnitTestForRoot
extra["flipcash.kmpUnitTestModules"] = kmpUnitTestForRoot
}
configurations.configureEach {
exclude(mapOf("group" to "org.jetbrains.kotlin", "module" to "kotlin-stdlib-jdk7"))
resolutionStrategy.force(*forcedDependencies.toTypedArray())
}
tasks.matching { task -> task.name.contains("kapt") }.configureEach {
enabled = false
}
tasks.withType(org.gradle.api.tasks.testing.Test::class.java).configureEach {
jvmArgs(robolectricJvmArgs)
}
}
}