diff --git a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/AppVersion.jvm.kt b/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/AppVersion.jvm.kt deleted file mode 100644 index 65ea6ee4..00000000 --- a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/AppVersion.jvm.kt +++ /dev/null @@ -1,8 +0,0 @@ -package ac.cord.auxiliary.compose - -actual object AppVersion { - actual val versionName: String - get() = "0.0.1" - actual val versionCode: String - get() = "21" -} \ No newline at end of file diff --git a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/Platform.jvm.kt b/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/Platform.jvm.kt deleted file mode 100644 index cbce9a9b..00000000 --- a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/Platform.jvm.kt +++ /dev/null @@ -1,7 +0,0 @@ -package ac.cord.auxiliary.compose - -class JVMPlatform: Platform { - override val name: String = "Java ${System.getProperty("java.version")}" -} - -actual fun getPlatform(): Platform = JVMPlatform() \ No newline at end of file diff --git a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/PlatformContext.jvm.kt b/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/PlatformContext.jvm.kt deleted file mode 100644 index b52de0a8..00000000 --- a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/PlatformContext.jvm.kt +++ /dev/null @@ -1,3 +0,0 @@ -package ac.cord.auxiliary.compose - -actual class PlatformContext \ No newline at end of file diff --git a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/database/builder/PlatformDatabaseBuilder.jvm.kt b/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/database/builder/PlatformDatabaseBuilder.jvm.kt deleted file mode 100644 index f78769a7..00000000 --- a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/database/builder/PlatformDatabaseBuilder.jvm.kt +++ /dev/null @@ -1,20 +0,0 @@ -package ac.cord.auxiliary.compose.database.builder - -import ac.cord.auxiliary.compose.PlatformContext -import ac.auxiliary.compose.database.AuxDatabase -import androidx.room.Room -import androidx.room.RoomDatabase -import java.io.File - -actual object PlatformDatabaseBuilder { - actual fun getDatabaseBuilder(platformContext: PlatformContext): RoomDatabase.Builder { - val dbFile = File(System.getProperty("java.io.tmpdir"), "aux.db") // TODO: Stop using tmpDir on desktop... - return Room.databaseBuilder( - name = dbFile.absolutePath, - ) - } - - actual fun getInMemoryDatabaseBuilder(platform: PlatformContext): RoomDatabase.Builder { - return Room.inMemoryDatabaseBuilder() - } -} \ No newline at end of file diff --git a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/main.kt b/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/main.kt deleted file mode 100644 index 4a4fd9ed..00000000 --- a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/main.kt +++ /dev/null @@ -1,20 +0,0 @@ -package ac.cord.auxiliary.compose - -import androidx.compose.ui.window.Window -import androidx.compose.ui.window.application -import androidx.navigation.compose.rememberNavController - -fun main() = application { - Window( - onCloseRequest = ::exitApplication, - title = "Torch", - ) { - val navController = rememberNavController() - AuxApp( - navController = navController, - auxGlobal = AuxGlobal( - platformContext = PlatformContext() - ) - ) - } -} \ No newline at end of file diff --git a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/ui/theme/Theme.jvm.kt b/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/ui/theme/Theme.jvm.kt deleted file mode 100644 index 79e272fe..00000000 --- a/composeApp/src/jvmMain/kotlin/ac/cord/auxiliary/compose/ui/theme/Theme.jvm.kt +++ /dev/null @@ -1,17 +0,0 @@ -package ac.cord.auxiliary.compose.ui.theme - -import androidx.compose.material3.ColorScheme -import androidx.compose.runtime.Composable - -@Composable -actual fun themeColorScheme( - darkTheme: Boolean, - dynamicColor: Boolean, - darkScheme: ColorScheme, - lightScheme: ColorScheme -): ColorScheme { - return when { - darkTheme -> darkScheme - else -> lightScheme - } -} \ No newline at end of file diff --git a/docs/jvm-target.md b/docs/jvm-target.md index 982625bb..fcb19ce7 100644 --- a/docs/jvm-target.md +++ b/docs/jvm-target.md @@ -90,25 +90,56 @@ Nothing here needs a decision; it is the groundwork the later phases assume. 2. **Add the missing catalog entries** to `gradle/libs.versions.toml`: ```toml - androidx-room3-runtime-jvm = { module = "androidx.room3:room3-runtime-jvm", version.ref = "room3" } androidx-sqlite-bundled-jvm = { module = "androidx.sqlite:sqlite-bundled-jvm", version.ref = "sqlite" } - sqldelight-jdbc-driver = { module = "app.cash.sqldelight:jdbc-driver", version.ref = "sqldelight" } - sqldelight-sqlite-driver = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" } + sqldelight-sqlite-driver = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" } ``` -3. **Wire KSP for the JVM target.** Uncomment - [composeApp/build.gradle.kts:194](../composeApp/build.gradle.kts). Without it - there is no generated `MantraDatabase_Impl` or DAO implementation for the - host, and `MantraDatabaseConstructor` has no JVM actual — Room's KSP generates - that one, so it costs nothing once the processor runs. + Only these two, and only because neither can be reached any other way. + `sqlite-bundled-jvm` has to be named explicitly because variant-aware + resolution hands the *android* artifact to anything running on the host — + that is the whole trap described in the appendix. `sqlite-driver` is the jvm + counterpart to the `android-driver` and `native-driver` entries already here. -4. **Leave `jvm()` commented out for now**, in both builds. It goes on at the - start of Phase 4, once there is something for it to resolve against. Turning - it on earlier just means living with a broken build through Phases 1–3. + No `room3-runtime-jvm` entry: once `jvm()` exists, `commonMain`'s existing + `androidx-room3-runtime` resolves to the `-jvm` variant on its own. And the + SQLDelight drivers Phase 2 needs belong in **lightning-kmp-app's own + catalog**, not this one — that is a separate gradle build with a separate + version catalog, and putting them here would not make them visible there. + +3. **Do not wire `kspJvm` yet.** It cannot be done at this point, and the reason + is already written down a few lines above it in the build file: + + > These configurations only exist when the ios targets are declared, which + > the kotlin block above does only on a mac. + + The same rule governs `kspJvm` — `dependencies { add("kspJvm", ...) }` throws + `UnknownConfigurationException` until a `jvm()` target creates that + configuration. So uncommenting [composeApp/build.gradle.kts:194](../composeApp/build.gradle.kts) + belongs in **Phase 4**, in the same edit that turns the target on, not here. + +4. **Leave `jvm()` commented out**, in both builds. It goes on at the start of + Phase 4, once there is something for it to resolve against. Turning it on + earlier just means living with a broken build through Phases 1–3. **Verification:** `./gradlew :composeApp:compileDebugKotlinAndroid` still passes. This phase changes nothing observable; the point is that it changes nothing -observable. +observable — a deleted orphan source set and two unreferenced catalog entries +cannot alter a build. + +**If you are working in a git worktree, no gradle task will run at all** until +the submodule is checked out there. Worktrees do not get submodules +automatically, so `lightning-kmp-app/` is empty and the composite build fails +during configuration: + +``` +Project with path ':library' not found in build ':lightning-kmp-app' +``` + +`git submodule update --init --recursive` fixes it, but note that a linked +worktree shares `.git/modules/` with the main checkout, so both trees end up +sharing one submodule git dir. That is fine while both want the same commit — +check with `git submodule status` in each — and worth being careful about when +they do not. --- @@ -233,7 +264,11 @@ review it attracts. **~1–2 days. Blocked by Phases 1–3.** Now turn on `jvm()` — [composeApp/build.gradle.kts:46](../composeApp/build.gradle.kts) -and `lightning-kmp-app/library/build.gradle.kts:18` — and let the compiler drive. +and `lightning-kmp-app/library/build.gradle.kts:18` — and, in the same edit, +uncomment `kspJvm` at [composeApp/build.gradle.kts:194](../composeApp/build.gradle.kts). +Those two go together: the KSP configuration does not exist until the target +does, which is why Phase 0 deliberately left it alone. Then let the compiler +drive. Mantra declares 16 expects across 8 files. They split cleanly: @@ -246,7 +281,7 @@ update Room 2 → Room 3 (`androidx.room` → `androidx.room3`), and point at `MantraDatabase` instead of `AuxDatabase`. `MantraDatabaseConstructor` needs no hand-written actual; Room's KSP generates it -once Phase 0 wired `kspJvm`. +once `kspJvm` is wired above. For `PlatformDatabaseBuilder.getDatabaseBuilder`, use the real application data directory from Phase 1 — not `java.io.tmpdir`, which is what the old Aux diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e51ecfde..0c5a0d8b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,6 +42,7 @@ androidx-activity-compose = { module = "androidx.activity:activity-compose", ver androidx-datastore = { module = "androidx.datastore:datastore", version.ref = "datastorePreferences" } androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" } androidx-sqlite-bundled = { module = "androidx.sqlite:sqlite-bundled", version.ref = "sqlite" } +androidx-sqlite-bundled-jvm = { module = "androidx.sqlite:sqlite-bundled-jvm", version.ref = "sqlite" } androidx-room3-runtime = { module = "androidx.room3:room3-runtime", version.ref = "room3" } androidx-room3-compiler = { module = "androidx.room3:room3-compiler", version.ref = "room3" } androidx-room3-sqlite-wrapper = { module = "androidx.room3:room3-sqlite-wrapper", version.ref = "room3" } @@ -78,6 +79,7 @@ sqldelight-android-driver = { module = "app.cash.sqldelight:android-driver", ver sqldelight-coroutines-extensions = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sqldelight" } sqldelight-native-driver = { module = "app.cash.sqldelight:native-driver", version.ref = "sqldelight" } sqldelight-runtime = { module = "app.cash.sqldelight:runtime", version.ref = "sqldelight" } +sqldelight-sqlite-driver = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" } vitorpamplona-quartz = { module = "com.vitorpamplona.quartz:quartz", version.ref = "quartz" } [plugins]