Verbatim M4.2 (:core:domain) playbook — both source files moved UNMODIFIED
into commonMain (git records the rename; UserSettings.kt is a pure rename).
This is the visibility gate for M4.3's AppGraph: a KMP commonMain cannot see
plain kotlin("jvm") modules, and M4.3's container seam needs
SettingsRepository/UserSettings from composeApp commonMain.
One new seam, justified per §9 (never widen silently): kotlinx.coroutines
`runBlocking` has no commonMain declaration, so SettingsRepository.snapshot()
now goes through an internal expect/actual `blockingFirst(Flow<T>): T`.
Both actuals are the identical two-liner because both targets are JVM.
Same startup-safety contract (block off the UI thread at startup only).
Consumers unchanged by design: :desktopApp (plain jvm) and :composeApp's
androidMain resolve through variant metadata — zero import changes.
Verification (both green):
./gradlew assembleDebug :composeApp:compileKotlinJvm :core:data-jvm:smoke
→ BUILD SUCCESSFUL — RESULT: M1a PASS (one run, all consumers)
./gradlew :desktopApp:run --args="--data-dir /tmp/incido-desktop-smoke --self-test --exit-after 6"
→ SELFTEST wrote note id=1 → RENDER notes=1 selected=1
git diff core/data/objectbox-models → empty (ID model file unchanged)
59 lines
2.3 KiB
Kotlin
59 lines
2.3 KiB
Kotlin
// core/settings — Phase 1 (M3 task 1): user settings, extracted from
|
|
// :composeApp so the desktop build reads and writes the SAME preferences
|
|
// file format the phone uses (`.preferences_pb`, identical keys).
|
|
//
|
|
// Phase 1 (M4.3a): converted kotlin("jvm") → kotlin("multiplatform") with
|
|
// androidTarget() + jvm(), the exact M4.2 (:core:domain) playbook. This is
|
|
// what makes SettingsRepository/UserSettings visible to a KMP commonMain —
|
|
// the gate M4.3's AppGraph needs (plain kotlin("jvm") modules are invisible
|
|
// to commonMain). Sources moved UNMODIFIED into commonMain except one two-
|
|
// line seam: runBlocking has no commonMain declaration, so snapshot() goes
|
|
// through expect/actual `blockingFirst` (both actuals identical — both our
|
|
// targets are JVM). Consumers unchanged by design: :desktopApp (plain jvm)
|
|
// and :composeApp (AGP + KMP) resolve through variant metadata.
|
|
//
|
|
// The one M3 API shape stands: SettingsRepository takes an injected
|
|
// DataStore<Preferences> instead of a Context — Android supplies the
|
|
// `preferencesDataStore(name = …)` Context-extension store, desktop builds
|
|
// one with PreferenceDataStoreFactory.create(produceFile = …) (the spike
|
|
// finding: the multiplatform core artifact has no Context extension).
|
|
|
|
plugins {
|
|
alias(libs.plugins.androidLibrary)
|
|
alias(libs.plugins.kotlinMultiplatform)
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(17)
|
|
|
|
androidTarget()
|
|
jvm()
|
|
|
|
sourceSets {
|
|
commonMain.dependencies {
|
|
// Public API (constructor + flow types) exposes DataStore<Preferences> —
|
|
// api, not impl. On the Android classpath this resolves to the same
|
|
// android variant :composeApp's datastore-preferences already pulls, so
|
|
// there is no duplicate-class situation. The 1.1.1 artifact is itself
|
|
// multiplatform (its jvm variant is what the plain-JVM desktop build
|
|
// has been resolving all along).
|
|
api(libs.androidx.datastore.preferences.core)
|
|
implementation(libs.kotlinx.coroutines.core)
|
|
}
|
|
}
|
|
}
|
|
|
|
android {
|
|
namespace = "org.incido.compose.data.settings"
|
|
compileSdk = 35
|
|
|
|
defaultConfig {
|
|
minSdk = 26
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
}
|