From fbc473ac7a24a20ed5bb077a792ec6b06cba92ef Mon Sep 17 00:00:00 2001 From: mikolaj Date: Mon, 2 Nov 2026 01:35:52 +0100 Subject: [PATCH 1/2] chore: version 2.0.0-alpha04-SNAPSHOT Co-Authored-By: Claude Opus 5.5 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0b60b6c..e713914 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } // Every published version is immutable on the Portal: bump before publishing, and never reuse one. -version = "2.0.0-alpha03" +version = "2.0.0-alpha04-SNAPSHOT" group = "io.github.lemcoder" repositories { From fe711e6a4b636d9e3322dff7bdfbc1053234f645 Mon Sep 17 00:00:00 2001 From: mikolaj Date: Mon, 2 Nov 2026 22:31:07 +0100 Subject: [PATCH 2/2] fix: generated KMP JNI sources carry their producer addKmpJvmSources added the generated directory through a provider of its own, which carries no producer, and patched only the compile tasks with dependsOn. Any other reader of the source set raced generation: a published Android or jvm() sources jar failed Gradle's implicit-dependency check. The directory is now a file collection built by the generation task, so every reader depends on it. Co-Authored-By: Claude Opus 5.5 --- .../io/github/lemcoder/kotlin/KotlinGradlePlugin.kt | 11 +++++------ .../io/github/lemcoder/KonanPluginFunctionalTest.kt | 10 ++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/io/github/lemcoder/kotlin/KotlinGradlePlugin.kt b/src/main/kotlin/io/github/lemcoder/kotlin/KotlinGradlePlugin.kt index 82f49a9..60aa719 100644 --- a/src/main/kotlin/io/github/lemcoder/kotlin/KotlinGradlePlugin.kt +++ b/src/main/kotlin/io/github/lemcoder/kotlin/KotlinGradlePlugin.kt @@ -36,16 +36,15 @@ internal object KotlinGradlePlugin { /** …and of the main compilation of every JVM and Android target of a multiplatform project. */ fun addKmpJvmSources(project: Project, sources: Provider, generate: TaskProvider<*>, enabled: () -> Boolean) { // Decided when the sources are read, not now: targets are usually declared before konan { }. A - // provider of our own carries no producer, so the compile's dependency is spelled out too. - val lazySources = project.provider { if (enabled()) listOf(sources.get()) else emptyList() } + // provider of our own carries no producer, so the directory is built by the generation explicitly: + // every reader of the source set — the compile, a sources jar, lint — then depends on it. val lazyGenerate = project.provider { if (enabled()) listOf(generate) else emptyList() } + val lazySources = project.files(project.provider { if (enabled()) listOf(sources.get()) else emptyList() }) + .builtBy(lazyGenerate) project.extensions.getByType(KotlinMultiplatformExtension::class.java).targets .matching { it.platformType in JVM_PLATFORMS } .configureEach { - compilations.matching { it.name == "main" }.configureEach { - defaultSourceSet.kotlin.srcDir(lazySources) - compileTaskProvider.configure { dependsOn(lazyGenerate) } - } + compilations.matching { it.name == "main" }.configureEach { defaultSourceSet.kotlin.srcDir(lazySources) } } } diff --git a/src/test/kotlin/io/github/lemcoder/KonanPluginFunctionalTest.kt b/src/test/kotlin/io/github/lemcoder/KonanPluginFunctionalTest.kt index 43044dd..ddc577c 100644 --- a/src/test/kotlin/io/github/lemcoder/KonanPluginFunctionalTest.kt +++ b/src/test/kotlin/io/github/lemcoder/KonanPluginFunctionalTest.kt @@ -936,6 +936,16 @@ class KonanPluginFunctionalTest { assertTrue(":generateJniMymath SKIPPED" in result.output, result.output) } + @Test + fun `a multiplatform jvm() target's sources jar is built after its JNI bindings are generated`() { + write("""kotlin("multiplatform")${"\n"}id("io.github.lemcoder.konanplugin")""", mymath) + File(projectDir, "build.gradle.kts").appendText("kotlin { jvm() }\nrepositories { mavenCentral() }\n") + + val result = runner("jvmSourcesJar", "--dry-run").withPluginClasspathAndKgp().build() + + assertTrue(":generateJniMymath SKIPPED" in result.output, result.output) + } + @Test fun `ffm() serves a multiplatform project's jvm() targets in place of JNI`() { write("""kotlin("multiplatform")${"\n"}id("io.github.lemcoder.konanplugin")""", mymath.replace("library(mymath)", "library(mymath)\n ffm()"))