Files
Incido/core/data-jvm/build.gradle.kts
T
Incido Developer 29288b0370 test(m2): make :core:data-jvm:smoke idempotent — wipe its probe library in doFirst
The probe asserts exact note counts; running it twice in a row against the surviving build/data-jvm-smoke directory failed on count assertions (found while verifying m2.5). The task now cleans the directory like backupSmoke does.
2026-10-05 19:48:54 +13:00

125 lines
4.8 KiB
Kotlin

// core/data-jvm — the DESKTOP build of the same data layer the Android app
// compiles (Development Plan §6, Phase 1 milestone M1a).
//
// Shape: sibling JVM module sharing :core:data's platform-neutral sources,
// NOT one multiplatform module. Two reasons, both proven in the Phase-0
// spike (tools/DESKTOP_FEASIBILITY.md):
// 1. ObjectBox's generator cannot read Kotlin common code, so entities have
// to be compiled per-target anyway.
// 2. objectbox-android and objectbox-java ship the same io.objectbox.*
// classes; keeping them in separate modules is what stops a duplicate
// classpath clash. Each module runs its own codegen and gets its own
// MyObjectBox.
// The shared model file is copied to objectbox-models/, and regenerating in a
// second module reports "ID model file unchanged" — no UID churn.
// The ObjectBox Gradle plugin publishes no plugin marker (same reason
// :core/data/build.gradle.kts wires it through a buildscript classpath).
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("io.objectbox:objectbox-gradle-plugin:${libs.versions.objectbox.get()}")
}
}
plugins {
alias(libs.plugins.kotlinJvm)
}
// SPIKE FINDING: `alias(libs.plugins.kotlinKapt)` fails here ("plugin is
// already on the classpath with an unknown version") because the root build
// already loads the Kotlin Gradle Plugin, which ships kapt. Applying by id
// reuses that copy.
apply(plugin = "org.jetbrains.kotlin.kapt")
apply(plugin = "io.objectbox")
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
sourceSets {
main {
kotlin.setSrcDirs(
listOf(
"build/generated/source/objectbox",
"src/main/kotlin",
// The platform-neutral data layer, compiled from :core:data's
// directory. Nothing in here may import android.*.
"../data/src/main/kotlin",
),
)
}
}
dependencies {
api(project(":core:domain"))
implementation(libs.kotlinx.coroutines.core)
// Phase 1 (M2): the backup bridge, for the backupSmoke round-trip probe.
// No classpath risk here — :core:backup carries no ObjectBox at all.
implementation(project(":core:backup"))
implementation(libs.kotlinx.serialization.json)
// JVM counterparts of the objectbox-android the Android build uses.
implementation(libs.objectbox.java)
implementation(libs.objectbox.kotlin)
// Native database library for the build/host OS. Declared explicitly so a
// packaged desktop app knows what it must bundle (objectbox-macos /
// objectbox-windows on other platforms).
runtimeOnly(libs.objectbox.linux)
}
/**
* `./gradlew :core:data-jvm:smoke` — boots the shared data layer against a
* real ObjectBox store on the JVM and round-trips a note. Temporary until
* :desktopApp provides the real entry point (Phase 1, M1b).
*/
tasks.register<JavaExec>("smoke") {
group = "verification"
description = "Opens a JVM ObjectBox store through the shared data layer."
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("org.incido.data.jvm.StoreSmokeKt")
val smokeDir = layout.buildDirectory.dir("data-jvm-smoke").get().asFile
args = listOf(smokeDir.absolutePath)
// The probe asserts exact note counts, so it needs a virgin library —
// wipe the directory here to keep `smoke` idempotent across runs.
doFirst { smokeDir.deleteRecursively() }
}
/**
* `./gradlew :core:data-jvm:backupSmoke --args="<backup.incido.json> [libDir]"`
* — feeds a REAL Android backup file through the :core:backup bridge on the
* JVM: preview, import into a fresh library, re-export and compare, then the
* encrypted-envelope path (including wrong-passphrase rejection). Runs
* against a fresh library every time (the script deletes libDir first).
*/
tasks.register<JavaExec>("backupSmoke") {
group = "verification"
description = "Round-trips a real Android backup export through BackupBridge on the JVM."
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("org.incido.data.jvm.BackupRoundTripKt")
}
/**
* `./gradlew :core:data-jvm:backupMemory` — synthesizes worst-case
* libraries and samples heap peak during BackupBridge.exportPlain
* (Phase 1, M2 task 5: measure & record, no redesign). Needs a bigger
* heap than the other probes on purpose — the "watch tier" is ~320 MB of
* attachments and the bridge holds the whole JSON in memory by design.
*/
tasks.register<JavaExec>("backupMemory") {
group = "verification"
description = "Measures export heap peaks on synthesized worst-case libraries (M2 t5)."
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("org.incido.data.jvm.BackupMemoryProbeKt")
maxHeapSize = "2g"
}