Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions kotlinx-coroutines-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.artifact_disambiguating_module")
}

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?.let {
attributes("Automatic-Module-Name" to it)
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions kotlinx-coroutines-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ kotlin {
}
}
}

val allMetadataJar by tasks.getting(Jar::class) {
manifest {
attributes("Automatic-Module-Name" to "kotlinx.coroutines.test.artifact_disambiguating_module")
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this logic affects all multiplatform projects, would kotlin-multiplatform-conventions be the better place to put it in?