Files
doctate/watch/wearos/app/build.gradle.kts
T
Brummel 24644a0144 feat(watch): replace CaseStoreStub with disk-backed CaseStore
Per-case JSON markers under filesDir/recordings/cases/, atomic tmp+rename
writes, kotlinx.coroutines Mutex serialising mutations. Wire format mirrors
doctate-client-core::CaseMarker exactly (snake_case keys, RFC3339 strings,
internally-tagged OnelinerState) — markers round-trip with the desktop client.

mergeServerSnapshot adds/updates only; reconcileWithServerSnapshot removes
synced markers inside the response window that the server stopped reporting.
Pending markers are never touched. Local Manual oneliners stick against
non-Manual server overrides.

DoctateApp now exposes caseStore as a lazy property and wires a
distinct-head flow collector to TileService.requestUpdate, decoupling
the store from Android Tile APIs (testable on the JVM).

JVM test infra: real org.json:json:20240303 plus
testOptions.unitTests.isReturnDefaultValues=true to bypass android.jar
'not mocked' stubs for Log/JSONObject. 35 unit tests green incl. 13 new
DiskCaseStoreTest cases (bootstrap, merge/reconcile semantics, mutex
ordering).
2026-04-26 23:35:00 +02:00

117 lines
4.1 KiB
Kotlin

import java.util.Properties
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
}
android {
namespace = "com.doctate.watch"
compileSdk {
version = release(36) {
minorApiLevel = 1
}
}
defaultConfig {
applicationId = "com.doctate.watch"
minSdk = 30
targetSdk = 36
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// Build-time config resolved in this order:
// 1. Gradle CLI property (-Pdoctate.serverUrl=...) — used by run.sh
// to switch between emulator and watch builds without touching
// local.properties.
// 2. local.properties (gitignored) — sticky per-developer default.
// 3. Hardcoded fallback — emulator loopback + sentinel key.
val localProps = Properties().apply {
rootProject.file("local.properties").takeIf { it.exists() }
?.inputStream()?.use { load(it) }
}
fun resolveProp(key: String, default: String): String =
(project.findProperty(key) as? String)
?: localProps.getProperty(key)
?: default
buildConfigField(
"String", "SERVER_URL",
"\"${resolveProp("doctate.serverUrl", "http://10.0.2.2:3000")}\""
)
buildConfigField(
"String", "API_KEY",
"\"${resolveProp("doctate.apiKey", "MISSING_API_KEY")}\""
)
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
useLibrary("wear-sdk")
buildFeatures {
compose = true
buildConfig = true
}
testOptions {
// Stub Android-framework methods (Log.i, etc.) return defaults instead of
// throwing "not mocked" — required for JVM unit tests of code that uses
// android.util.Log alongside core java APIs.
unitTests.isReturnDefaultValues = true
}
}
dependencies {
implementation(platform(libs.compose.bom))
implementation(libs.activity.compose)
implementation(libs.compose.foundation)
implementation(libs.compose.material3)
implementation(libs.compose.ui.tooling)
implementation(libs.core.splashscreen)
implementation(libs.play.services.wearable)
implementation(libs.ui)
implementation(libs.ui.graphics)
implementation(libs.ui.tooling.preview)
implementation(libs.wear.tooling.preview)
implementation(libs.wear.tiles)
implementation(libs.wear.protolayout)
implementation(libs.wear.protolayout.material3)
implementation(libs.wear.protolayout.expression)
implementation(libs.wear.complications.data.source.ktx)
implementation(libs.wear.compose.navigation)
implementation(libs.wear.input)
implementation(libs.guava)
androidTestImplementation(platform(libs.compose.bom))
androidTestImplementation(libs.ui.test.junit4)
debugImplementation(libs.ui.test.manifest)
debugImplementation(libs.ui.tooling)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.lifecycle.viewmodel.compose)
implementation(libs.lifecycle.runtime.compose)
implementation(libs.okhttp)
testImplementation(libs.junit)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.okhttp.mockwebserver)
testImplementation(libs.truth)
// Real org.json so JVM unit tests don't hit the "not mocked" stub from android.jar.
testImplementation("org.json:json:20240303")
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.okhttp.mockwebserver)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.kotlinx.coroutines.test)
}