From b17901973ca02e09404dac1fc7379423828c474b Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Sun, 2 Aug 2026 18:46:00 +0200 Subject: [PATCH] Add lightning-kmp-app as a commonMain dependency via JitPack The shared lightning/phoenix logic now lives in kngako/lightning-kmp-app, which publishes a single `:library` module. JitPack serves a repository's submodules under ., hence the com.github.kngako.lightning-kmp-app:library coordinate. The repository is content-filtered to com.github.kngako so it is not consulted for anything else -- an unfiltered jitpack.io entry gets asked about every dependency that misses in mavenCentral, and each miss is a remote round trip. The version is a commit rather than master-SNAPSHOT. For a -SNAPSHOT version JitPack advertises a unique-snapshot maven-metadata.xml (timestamp=, buildNumber=1) while serving the files under their literal -SNAPSHOT names, so gradle derives library--master--1 and gets a 404 on every artifact. Pinning a commit sidesteps the snapshot machinery entirely and is reproducible; it needs bumping when the fork moves. That leaves the classifier. JitPack rewrites the version inside a published .module file and drops the classifier while doing so, so both the sources and the host-specific metadata variants of each apple target come back naming library--.jar -- a file that does not exist, next to the -sources.jar and -metadata.jar that do. The klib and the aar are named without a classifier and so survive the rewrite, which is why the android compilation resolves this dependency perfectly well and only the metadata compilations fail. Every shared ios source set resolves through those, so a component metadata rule puts the -metadata classifier back. It is scoped to the two apple modules and to their metadata variant by name, so it cannot disturb the klib artifacts. Verified: :composeApp:compileCommonMainKotlinMetadata and :composeApp:compileDebugKotlinAndroid both pass. Co-Authored-By: Claude Opus 5 --- composeApp/build.gradle.kts | 32 ++++++++++++++++++++++++++++++++ gradle/libs.versions.toml | 5 +++++ settings.gradle.kts | 5 +++++ 3 files changed, 42 insertions(+) diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index e5e4f631..335ed72d 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -1,5 +1,6 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import javax.inject.Inject plugins { alias(libs.plugins.androidApplication) @@ -88,6 +89,7 @@ kotlin { + implementation(libs.lightning.kmp.app) implementation(libs.lightning.kmp.core) implementation(libs.navigation.compose) @@ -154,7 +156,37 @@ android { } } +// JitPack rewrites the version inside a published .module file, and in doing so drops the classifier +// from every artifact name -- so lightning-kmp-app's apple targets advertise their host-specific +// metadata as `library--.jar` when it is actually served as `...--metadata.jar`. +// The klib and the aar are unaffected (android compiles either way); this only bites the metadata +// compilations, which is what every shared ios source set resolves through. Restore the classifier. +abstract class RestoreJitPackClassifier @Inject constructor( + private val variant: String, +) : ComponentMetadataRule { + override fun execute(context: ComponentMetadataContext) { + val id = context.details.id + context.details.withVariant(variant) { + withFiles { + removeAllFiles() + addFile("${id.name}-${id.version}-metadata.jar") + } + } + } +} + dependencies { + components { + mapOf( + "library-iosarm64" to "iosArm64MetadataElements-published", + "library-iossimulatorarm64" to "iosSimulatorArm64MetadataElements-published", + ).forEach { (module, variant) -> + withModule("com.github.kngako.lightning-kmp-app:$module") { + params(variant) + } + } + } + debugImplementation(libs.compose.uiTooling) // ksp(libs.androidx.room3.compiler) add("kspAndroid", libs.androidx.room3.compiler) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 860979a2..6ba49df2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,6 +21,10 @@ kotlinx-datetime = "0.8.0" kotlinxSerialization = "1.11.0" ksp = "2.3.6" ktor = "3.5.0" +# pinned to a commit, not master-SNAPSHOT: jitpack advertises a unique-snapshot maven-metadata for +# -SNAPSHOT versions but serves the files under their literal -SNAPSHOT names, so gradle looks for +# library--master--1.klib and gets a 404. bump this when the fork moves. +lightningKmpApp = "59cc3e3c15" lightningKmpCore = "1.11.5" material3 = "1.10.0-alpha05" materialIconsCore = "1.7.3" @@ -76,6 +80,7 @@ ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" } ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } +lightning-kmp-app = { module = "com.github.kngako.lightning-kmp-app:library", version.ref = "lightningKmpApp" } lightning-kmp-core = { module = "fr.acinq.lightning:lightning-kmp-core", version.ref = "lightningKmpCore" } navigation-compose = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "navigationCompose" } okhttp-coroutines = { group = "com.squareup.okhttp3", name = "okhttp-coroutines", version.ref = "okhttp" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 6e6e3daf..96532c1c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,6 +25,11 @@ dependencyResolutionManagement { } } mavenCentral() + maven("https://jitpack.io") { + mavenContent { + includeGroupAndSubgroups("com.github.kngako") + } + } } }