1plugins { 2 id 'java-platform' 3} 4 5def name = project.name 6 7dependencies { 8 constraints { 9 rootProject.subprojects.each { 10 if (it.name == name) return 11 if (!it.plugins.hasPlugin('maven-publish')) return 12 evaluationDependsOn(it.path) 13 it.publishing.publications.all { 14 if (it.artifactId.endsWith("-kotlinMultiplatform")) return 15 if (it.artifactId.endsWith("-metadata")) return 16 // Skip platform artifacts (like *-linuxx64, *-macosx64) 17 // It leads to inconsistent bom when publishing from different platforms 18 // (e.g. on linux it will include only linuxx64 artifacts and no macosx64) 19 // It shouldn't be a problem as usually consumers need to use generic *-native artifact 20 // Gradle will choose correct variant by using metadata attributes 21 if (it.artifacts.any { it.extension == 'klib' }) return 22 api("${it.groupId}:${it.artifactId}:${it.version}") 23 } 24 } 25 } 26} 27 28publishing { 29 publications { 30 mavenBom(MavenPublication) { 31 from components.javaPlatform 32 } 33 // Disable metadata publication, no need to 34 it.each { pub -> 35 pub.moduleDescriptorGenerator = null 36 tasks.matching { it.name == "generateMetadataFileFor${pub.name.capitalize()}Publication" }.all { 37 onlyIf { false } 38 } 39 } 40 } 41} 42