Skip to content

Commit 48ad741

Browse files
committed
Final touches
1 parent a723c9a commit 48ad741

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

buildSrc/src/main/kotlin/version-file-conventions.gradle.kts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import org.gradle.api.tasks.bundling.*
22

3-
/* `kotlinx-coroutines-debug` configures `VersionFile` on its own when the corresponding task is created. */
4-
val invalidModules = listOf("kotlinx-coroutines-debug")
5-
6-
configure(subprojects.filter {
7-
!unpublished.contains(it.name) && !invalidModules.contains(it.name) && it.name !in sourceless
8-
}) {
3+
configure(subprojects.filter { !unpublished.contains(it.name) && it.name !in sourceless }) {
94
val project = this
10-
val jarTaskName = if (isMultiplatform) "jvmJar" else "jar"
5+
val jarTaskName = when {
6+
project.name == "kotlinx-coroutines-debug" -> "shadowJar"
7+
isMultiplatform -> "jvmJar"
8+
else -> "jar"
9+
}
1110
val versionFileTask = VersionFile.registerVersionFileTask(project)
1211
tasks.withType(Jar::class.java).configureEach {
1312
if (name == jarTaskName) {

kotlinx-coroutines-debug/build.gradle.kts

+11-13
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import java.net.*
77
import java.nio.file.*
88

99
plugins {
10-
id("com.github.johnrengelman.shadow")
11-
id("org.jetbrains.kotlinx.kover") // apply plugin to use autocomplete for Kover DSL
10+
id("com.github.johnrengelman.shadow")
11+
id("org.jetbrains.kotlinx.kover") // apply plugin to use autocomplete for Kover DSL
1212
}
1313

14-
configurations{
14+
configurations {
1515
val shadowDeps by creating
1616
compileOnly.configure {
1717
extendsFrom(shadowDeps)
@@ -58,8 +58,6 @@ val jar by tasks.existing(Jar::class) {
5858
enabled = false
5959
}
6060

61-
val versionFileTask = VersionFile.registerVersionFileTask(project)
62-
6361
val shadowJar by tasks.existing(ShadowJar::class) {
6462
// Shadow only byte buddy, do not package kotlin stdlib
6563
configurations = listOf(project.configurations["shadowDeps"])
@@ -72,17 +70,17 @@ val shadowJar by tasks.existing(ShadowJar::class) {
7270
archiveBaseName.set(jar.flatMap { it.archiveBaseName })
7371
archiveVersion.set(jar.flatMap { it.archiveVersion })
7472
manifest {
75-
attributes(mapOf(
76-
"Premain-Class" to "kotlinx.coroutines.debug.AgentPremain",
77-
"Can-Redefine-Classes" to "true",
78-
"Multi-Release" to "true"
79-
))
73+
attributes(
74+
mapOf(
75+
"Premain-Class" to "kotlinx.coroutines.debug.AgentPremain",
76+
"Can-Redefine-Classes" to "true",
77+
"Multi-Release" to "true"
78+
)
79+
)
8080
}
81-
VersionFile.fromVersionFile(this, versionFileTask)
82-
duplicatesStrategy = DuplicatesStrategy.FAIL
81+
// add module-info.class to the META-INF/versions/9/ directory.
8382
dependsOn(tasks.compileModuleInfoJava)
8483
doLast {
85-
// add module-info.class to the META-INF/versions/9/ directory.
8684
// We can't do that directly with the shadowJar task because it doesn't support replacing existing files.
8785
val zipPath = this@existing.outputs.files.singleFile.toPath()
8886
val zipUri = URI.create("jar:${zipPath.toUri()}")

0 commit comments

Comments
 (0)