Skip to content

Commit c98c47d

Browse files
committed
Specify Automatic-Module-Name for kotlinx-coroutines-core
Fixes #3842
1 parent ea39bf3 commit c98c47d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Add dependencies (you can also add other modules that you need):
8585
```xml
8686
<dependency>
8787
<groupId>org.jetbrains.kotlinx</groupId>
88-
<artifactId>kotlinx-coroutines-core</artifactId>
88+
<artifactId>kotlinx-coroutines-core-jvm</artifactId>
8989
<version>1.10.1</version>
9090
</dependency>
9191
```

kotlinx-coroutines-core/build.gradle.kts

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import org.gradle.api.tasks.testing.*
2-
import org.gradle.kotlin.dsl.*
31
import org.jetbrains.kotlin.gradle.plugin.mpp.*
42
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
53
import org.jetbrains.kotlin.gradle.tasks.*
@@ -182,15 +180,23 @@ val jvmJar by tasks.getting(Jar::class) { setupManifest(this) }
182180
* This manifest contains reference to AgentPremain that belongs to
183181
* kotlinx-coroutines-core-jvm, but our resolving machinery guarantees that
184182
* any JVM project that depends on -core artifact also depends on -core-jvm one.
183+
*
184+
* To avoid a conflict with a JPMS module provided by kotlinx-coroutines-core-jvm,
185+
* an explicit automatic module name has to be specified in the manifest.
185186
*/
186-
val allMetadataJar by tasks.getting(Jar::class) { setupManifest(this) }
187+
val allMetadataJar by tasks.getting(Jar::class) {
188+
setupManifest(this, "kotlinx.coroutines.core.trampoline")
189+
}
187190

188-
fun setupManifest(jar: Jar) {
191+
fun setupManifest(jar: Jar, autoModuleName: String? = null) {
189192
jar.manifest {
190-
attributes(mapOf(
193+
attributes(
191194
"Premain-Class" to "kotlinx.coroutines.debug.internal.AgentPremain",
192-
"Can-Retransform-Classes" to "true",
193-
))
195+
"Can-Retransform-Classes" to "true"
196+
)
197+
autoModuleName?.also {
198+
attributes("Automatic-Module-Name" to it)
199+
}
194200
}
195201
}
196202

0 commit comments

Comments
 (0)