xref: /aosp_15_r20/external/kotlinx.coroutines/kotlinx-coroutines-bom/build.gradle.kts (revision 7a7160fed73afa6648ef8aa100d4a336fe921d9a)

<lambda>null1 import org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication
2 
3 plugins {
4     id("java-platform")
5 }
6 
7 val name = project.name
8 
<lambda>null9 dependencies {
10     constraints {
11         rootProject.subprojects.forEach {
12             if (unpublished.contains(it.name)) return@forEach
13             if (it.name == name) return@forEach
14             if (!it.plugins.hasPlugin("maven-publish")) return@forEach
15             evaluationDependsOn(it.path)
16             it.publishing.publications.all {
17                 this as MavenPublication
18                 if (artifactId.endsWith("-kotlinMultiplatform")) return@all
19                 if (artifactId.endsWith("-metadata")) return@all
20                 // Skip platform artifacts (like *-linuxx64, *-macosx64)
21                 // It leads to inconsistent bom when publishing from different platforms
22                 // (e.g. on linux it will include only linuxx64 artifacts and no macosx64)
23                 // It shouldn't be a problem as usually consumers need to use generic *-native artifact
24                 // Gradle will choose correct variant by using metadata attributes
25                 if (artifacts.any { it.extension == "klib" }) return@all
26                 this@constraints.api(mapOf("group" to groupId, "name" to artifactId, "version" to version))
27             }
28         }
29     }
30 }
31 
<lambda>null32 publishing {
33     publications {
34         val mavenBom by creating(MavenPublication::class) {
35             from(components["javaPlatform"])
36         }
37         // Disable metadata publication
38         forEach { pub ->
39             pub as DefaultMavenPublication
40             pub.unsetModuleDescriptorGenerator()
41             tasks.matching { it.name == "generateMetadataFileFor${pub.name.capitalize()}Publication" }.all {
42                 onlyIf { false }
43             }
44         }
45     }
46 }
47 
unsetModuleDescriptorGeneratornull48 fun DefaultMavenPublication.unsetModuleDescriptorGenerator() {
49     @Suppress("NULL_FOR_NONNULL_TYPE")
50     val generator: TaskProvider<Task> = null
51     setModuleDescriptorGenerator(generator)
52 }
53