1 import org.gradle.kotlin.dsl.*
2
3 /*
4 * For some absolutely cursed reason the name 'publication-conventions' doesn't work in my IDE.
5 * TODO: recheck after full repair
6 */
<lambda>null7 plugins {
8 id("maven-publish")
9 id("signing")
10 }
11
12 apply(plugin = "maven-publish")
13 apply(plugin = "signing")
14
<lambda>null15 publishing {
16 repositories {
17 configureMavenPublication(this, project)
18 }
19
20 if (!isMultiplatform && !isBom) {
21 // Configure java publications for regular non-MPP modules
22 apply(plugin = "java-library")
23
24 // MPP projects pack their sources automatically, java libraries need to explicitly pack them
25 val sources = tasks.register("sourcesJar", Jar::class) {
26 archiveClassifier = "sources"
27 from(sourceSets.named("main").get().allSource)
28 }
29
30 publications {
31 register("mavenJava", MavenPublication::class) {
32 from(components["java"])
33 artifact(sources)
34 }
35 }
36 }
37
38 val emptyJavadoc = if (!isBom) registerEmptyJavadocArtifact() else null
39 publications.withType(MavenPublication::class).all {
40 pom.configureMavenCentralMetadata(project)
41 signPublicationIfKeyPresent(project, this)
42 if (!isBom && name != "kotlinMultiplatform") {
43 artifact(emptyJavadoc)
44 }
45
46 val type = name
47 when (type) {
48 "kotlinMultiplatform" -> {
49 // With Kotlin 1.4 & HMPP, the root module should have no suffix in the ID, but for compatibility with
50 // the consumers who can't read Gradle module metadata, we publish the JVM artifacts in it, too
51 artifactId = project.name
52 project.reconfigureMultiplatformPublication(publications.getByName("jvm") as MavenPublication)
53 }
54
55 "metadata", "jvm", "js", "native" -> {
56 artifactId = "${project.name}-$type"
57 }
58 }
59 }
60
61 project.establishSignDependencies()
62 }
63
64
65 // Legacy from https://github.com/Kotlin/kotlinx.coroutines/pull/2031
66 // Should be fixed with the rest of the hacks around publication
<lambda>null67 tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication" }.configureEach {
<lambda>null68 dependsOn(tasks.matching { it.name == "generatePomFileForJvmPublication" })
69 }
70
71 // Compatibility with old TeamCity configurations that perform :kotlinx-coroutines-core:bintrayUpload
<lambda>null72 tasks.register("bintrayUpload") { dependsOn(tasks.matching { it.name == "publish" }) }
73