From 3eac9a7257dfa302d3e4c8e36968a180e0ca8411 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Fri, 3 Jan 2025 16:58:49 -0500 Subject: [PATCH 1/4] Specify Automatic-Module-Name for kotlinx-coroutines-core Fixes #3842 # Conflicts: # README.md # kotlinx-coroutines-core/build.gradle.kts --- README.md | 2 +- kotlinx-coroutines-core/build.gradle.kts | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0f42da6090..2ee7ce3d06 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Add dependencies (you can also add other modules that you need): ```xml org.jetbrains.kotlinx - kotlinx-coroutines-core + kotlinx-coroutines-core-jvm 1.10.2 ``` diff --git a/kotlinx-coroutines-core/build.gradle.kts b/kotlinx-coroutines-core/build.gradle.kts index 4acdf18572..4dc6e0ccb7 100644 --- a/kotlinx-coroutines-core/build.gradle.kts +++ b/kotlinx-coroutines-core/build.gradle.kts @@ -160,17 +160,24 @@ val jvmJar by tasks.getting(Jar::class) { setupManifest(this) } * This manifest contains reference to AgentPremain that belongs to * kotlinx-coroutines-core-jvm, but our resolving machinery guarantees that * any JVM project that depends on -core artifact also depends on -core-jvm one. + * + * To avoid a conflict with a JPMS module provided by kotlinx-coroutines-core-jvm, + * an explicit automatic module name has to be specified in the manifest. */ -val allMetadataJar by tasks.getting(Jar::class) { setupManifest(this) } +val allMetadataJar by tasks.getting(Jar::class) { + setupManifest(this, "kotlinx.coroutines.core.trampoline") +} -fun setupManifest(jar: Jar) { +fun setupManifest(jar: Jar, autoModuleName: String? = null) { jar.manifest { attributes( - mapOf( + "Premain-Class" to "kotlinx.coroutines.debug.internal.AgentPremain", - "Can-Retransform-Classes" to "true", - ) + "Can-Retransform-Classes" to "true" ) + autoModuleName?.also { + attributes("Automatic-Module-Name" to it) + } } } From 7d744ef293280a072ad3f30a22b8611243685af9 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Tue, 7 Jan 2025 09:45:57 -0500 Subject: [PATCH 2/4] Update the module name and clean up the code --- kotlinx-coroutines-core/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kotlinx-coroutines-core/build.gradle.kts b/kotlinx-coroutines-core/build.gradle.kts index 4dc6e0ccb7..8a72bb2efb 100644 --- a/kotlinx-coroutines-core/build.gradle.kts +++ b/kotlinx-coroutines-core/build.gradle.kts @@ -165,7 +165,7 @@ val jvmJar by tasks.getting(Jar::class) { setupManifest(this) } * an explicit automatic module name has to be specified in the manifest. */ val allMetadataJar by tasks.getting(Jar::class) { - setupManifest(this, "kotlinx.coroutines.core.trampoline") + setupManifest(this, "kotlinx.coroutines.core.artifact_disambiguating_module") } fun setupManifest(jar: Jar, autoModuleName: String? = null) { @@ -175,7 +175,7 @@ fun setupManifest(jar: Jar, autoModuleName: String? = null) { "Premain-Class" to "kotlinx.coroutines.debug.internal.AgentPremain", "Can-Retransform-Classes" to "true" ) - autoModuleName?.also { + autoModuleName?.let { attributes("Automatic-Module-Name" to it) } } From d6c4a89b629c1c23d799686c0dfb81e2a8a5acfb Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Mon, 10 Nov 2025 12:22:44 -0500 Subject: [PATCH 3/4] Revert readme changes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ee7ce3d06..0f42da6090 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Add dependencies (you can also add other modules that you need): ```xml org.jetbrains.kotlinx - kotlinx-coroutines-core-jvm + kotlinx-coroutines-core 1.10.2 ``` From 4b5875c5bac87e67f9fa4c8a33d2215c3bd4278c Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Mon, 10 Nov 2025 12:33:04 -0500 Subject: [PATCH 4/4] Specify the auto-module name for the test artifact --- kotlinx-coroutines-test/build.gradle.kts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kotlinx-coroutines-test/build.gradle.kts b/kotlinx-coroutines-test/build.gradle.kts index 5e29e6ae75..db519b121f 100644 --- a/kotlinx-coroutines-test/build.gradle.kts +++ b/kotlinx-coroutines-test/build.gradle.kts @@ -21,3 +21,9 @@ kotlin { } } } + +val allMetadataJar by tasks.getting(Jar::class) { + manifest { + attributes("Automatic-Module-Name" to "kotlinx.coroutines.test.artifact_disambiguating_module") + } +}