diff --git a/README.md b/README.md index d39cf315e1..2ad89d1403 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.1 ``` diff --git a/kotlinx-coroutines-core/build.gradle.kts b/kotlinx-coroutines-core/build.gradle.kts index d6abbd7e8a..afebd53542 100644 --- a/kotlinx-coroutines-core/build.gradle.kts +++ b/kotlinx-coroutines-core/build.gradle.kts @@ -1,5 +1,3 @@ -import org.gradle.api.tasks.testing.* -import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.gradle.plugin.mpp.* import org.jetbrains.kotlin.gradle.targets.native.tasks.* import org.jetbrains.kotlin.gradle.tasks.* @@ -182,15 +180,23 @@ 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.artifact_disambiguating_module") +} -fun setupManifest(jar: Jar) { +fun setupManifest(jar: Jar, autoModuleName: String? = null) { jar.manifest { - attributes(mapOf( + attributes( "Premain-Class" to "kotlinx.coroutines.debug.internal.AgentPremain", - "Can-Retransform-Classes" to "true", - )) + "Can-Retransform-Classes" to "true" + ) + autoModuleName?.let { + attributes("Automatic-Module-Name" to it) + } } }