Skip to content

Commit c5a42da

Browse files
Sergey Shatunovqwwdfsad
Sergey Shatunov
authored andcommitted
Migrate BOM module to java-platform plugin
1 parent 8248fe4 commit c5a42da

File tree

4 files changed

+31
-21
lines changed

4 files changed

+31
-21
lines changed

build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ buildscript {
6262
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
6363
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version"
6464
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
65-
classpath "io.spring.gradle:dependency-management-plugin:$spring_dependency_management_version"
6665

6766
// JMH plugins
6867
classpath "com.github.jengelman.gradle.plugins:shadow:5.1.0"

gradle.properties

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ mocha_version=4.1.0
2626
mocha_headless_chrome_version=1.8.2
2727
mocha_teamcity_reporter_version=2.2.2
2828
source_map_support_version=0.5.3
29-
spring_dependency_management_version=1.0.8.RELEASE
3029

3130
# Settings
3231
kotlin.incremental.multiplatform=true

gradle/publish-bintray.gradle

+12-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
apply plugin: 'maven'
88
apply plugin: 'maven-publish'
9-
apply plugin: "com.github.johnrengelman.shadow"
109

1110
apply from: project.rootProject.file('gradle/maven-central.gradle')
1211

@@ -15,7 +14,16 @@ apply from: project.rootProject.file('gradle/maven-central.gradle')
1514
def isMultiplatform = project.name == "kotlinx-coroutines-core"
1615
def isBom = project.name == "kotlinx-coroutines-bom"
1716

18-
if (!isMultiplatform) {
17+
if (!isBom) {
18+
apply plugin: "com.github.johnrengelman.shadow"
19+
20+
// empty xxx-javadoc.jar
21+
task javadocJar(type: Jar) {
22+
archiveClassifier = 'javadoc'
23+
}
24+
}
25+
26+
if (!isMultiplatform && !isBom) {
1927
// Regular java modules need 'java-library' plugin for proper publication
2028
apply plugin: 'java-library'
2129

@@ -26,11 +34,6 @@ if (!isMultiplatform) {
2634
}
2735
}
2836

29-
// empty xxx-javadoc.jar
30-
task javadocJar(type: Jar) {
31-
archiveClassifier = 'javadoc'
32-
}
33-
3437
publishing {
3538
repositories {
3639
maven {
@@ -46,12 +49,7 @@ publishing {
4649
}
4750
}
4851

49-
if (isBom) {
50-
// Configure mavenBom publication
51-
publications {
52-
mavenBom(MavenPublication) {}
53-
}
54-
} else if (!isMultiplatform) {
52+
if (!isMultiplatform && !isBom) {
5553
// Configure java publications for regular non-MPP modules
5654
publications {
5755
maven(MavenPublication) {
@@ -106,4 +104,4 @@ task publishDevelopSnapshot() {
106104
}
107105

108106
// Compatibility with old TeamCity configurations that perform :kotlinx-coroutines-core:bintrayUpload
109-
task bintrayUpload(dependsOn: publish)
107+
task bintrayUpload(dependsOn: publish)

kotlinx-coroutines-bom/build.gradle

+19-5
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,37 @@
22
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44
plugins {
5-
id 'io.spring.dependency-management'
5+
id 'java-platform'
66
}
77

88
def name = project.name
99

10-
dependencyManagement {
11-
dependencies {
10+
dependencies {
11+
constraints {
1212
rootProject.subprojects.each {
13-
if (ext.unpublished.contains(it.name)) return
13+
if (rootProject.ext.unpublished.contains(it.name)) return
1414
if (it.name == name) return
1515
if (!it.plugins.hasPlugin('maven-publish')) return
1616
evaluationDependsOn(it.path)
1717
it.publishing.publications.all {
1818
if (it.artifactId.endsWith("-kotlinMultiplatform")) return
1919
if (it.artifactId.endsWith("-metadata")) return
20-
dependency(group: it.groupId, name: it.artifactId, version: it.version)
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)
2127
}
2228
}
2329
}
2430
}
31+
32+
publishing {
33+
publications {
34+
mavenBom(MavenPublication) {
35+
from components.javaPlatform
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)