Phase 1 milestone M1a (Development Plan §6, desktop track): make the whole
data layer usable from a non-Android build, without touching what the
Android app compiles.
:core:data splits its sources:
src/main/kotlin platform-neutral — entities, repository, field
crypto, NoteCryptoService. Compiled by BOTH
:core:data and :core:data-jvm. Must not import
android.*
src/androidMain/kotlin Android-only seam implementations.
Two seams were required, both identified by the Phase-0 spike:
ObjectBoxStore Context on Android, a directory on desktop. Same
FQN in sibling modules that are never on one
classpath — which is also what keeps
objectbox-android and objectbox-java (they ship
the same io.objectbox.* classes) apart.
ImageOrientationNormalizer EXIF rotation needs a bitmap decoder; the
implementation moved verbatim out of
NoteRepositoryImpl, which is now platform-free.
The parameter is required, not defaulted, so a
platform that forgets it fails the build.
New :core:data-jvm compiles those shared sources against objectbox-java /
objectbox-linux with its own codegen. `:core:data-jvm:smoke` runs the real
NoteRepositoryImpl (save + hashtags + attachment round-trip + close/reopen)
on the JVM: PASS, with the generator reporting "ID model file unchanged" —
one schema, two generated runtimes.
Also: .gitignore excluded **/objectbox-models/, so the schema contract was
never committed and a fresh clone regenerated UIDs. default.json is now
tracked; the rest of that directory stays ignored. This matters more now
that two modules generate from it.
Verified: :core:data-jvm:smoke PASS, assembleDebug green.
73 lines
2.2 KiB
Kotlin
73 lines
2.2 KiB
Kotlin
// core/data — ObjectBox-backed implementation of the domain repository.
|
|
// The ObjectBox Gradle plugin isn't published with a plugin marker, so we
|
|
// wire it through a buildscript classpath here.
|
|
|
|
buildscript {
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
}
|
|
dependencies {
|
|
// ObjectBox plugin classpath. Version is pinned via libs.versions.toml
|
|
// through a generated accessor; here we hard-code for clarity.
|
|
classpath("io.objectbox:objectbox-gradle-plugin:${libs.versions.objectbox.get()}")
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
alias(libs.plugins.androidLibrary)
|
|
alias(libs.plugins.kotlinAndroid)
|
|
}
|
|
|
|
// Apply the ObjectBox plugin AFTER the classpath is on the buildscript.
|
|
apply(plugin = "io.objectbox")
|
|
|
|
android {
|
|
namespace = "org.incido.data"
|
|
compileSdk = 35
|
|
|
|
defaultConfig {
|
|
minSdk = 26
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(17)
|
|
}
|
|
|
|
sourceSets {
|
|
getByName("main") {
|
|
// NOTE: srcDirs() *replaces* the set, so every directory this
|
|
// module compiles has to be listed here.
|
|
kotlin.srcDirs(
|
|
// ObjectBox generates a MyObjectBox class at build time.
|
|
"build/generated/source/objectbox",
|
|
// Phase 1 (M1a): the platform-neutral data layer. The SAME
|
|
// directory is compiled by :core:data-jvm for the desktop
|
|
// build — it must contain no android.* imports.
|
|
"src/main/kotlin",
|
|
// Android-only implementations of the platform seams
|
|
// (Context-based store bootstrap, EXIF rotation).
|
|
"src/androidMain/kotlin",
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation(project(":core:domain"))
|
|
implementation(libs.kotlinx.coroutines.core)
|
|
|
|
// ObjectBox runtime
|
|
implementation(libs.objectbox.android)
|
|
implementation(libs.objectbox.kotlin)
|
|
|
|
// v0.3.1.2 — EXIF orientation tag handling for image attachments
|
|
// (see NoteRepositoryImpl.normalizeImageOrientation).
|
|
implementation(libs.androidx.exifinterface)
|
|
}
|