• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4plugins {
5    id 'java-platform'
6}
7
8def name = project.name
9
10dependencies {
11    constraints {
12        rootProject.subprojects.each {
13            if (rootProject.ext.unpublished.contains(it.name)) return
14            if (it.name == name) return
15            if (!it.plugins.hasPlugin('maven-publish')) return
16            evaluationDependsOn(it.path)
17            it.publishing.publications.all {
18                if (it.artifactId.endsWith("-kotlinMultiplatform")) return
19                if (it.artifactId.endsWith("-metadata")) return
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 (it.artifacts.any { it.extension == 'klib' }) return
26                api(group: it.groupId, name: it.artifactId, version: it.version)
27            }
28        }
29    }
30}
31
32publishing {
33    publications {
34        mavenBom(MavenPublication) {
35            from components.javaPlatform
36        }
37        // Disable metadata publication
38        it.each { pub ->
39            pub.moduleDescriptorGenerator = null
40            tasks.matching { it.name == "generateMetadataFileFor${pub.name.capitalize()}Publication" }.all {
41                onlyIf { false }
42            }
43        }
44    }
45}
46