Skip to content

Commit e6592c4

Browse files
authored
Introduce coroutines platform to have all the dependencies aligned (#2952)
* Introduce coroutines platform to have all the dependencies aligned Fixes #2865
1 parent e60685f commit e6592c4

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

build.gradle

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
56
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
67
import org.jetbrains.kotlin.konan.target.HostManager
78
import org.jetbrains.dokka.gradle.DokkaTaskPartial
89

9-
apply plugin: 'jdk-convention'
10+
import static Projects.*
1011

11-
def coreModule = "kotlinx-coroutines-core"
12-
def testModule = "kotlinx-coroutines-test"
13-
def multiplatform = [coreModule, testModule]
14-
// Not applicable for Kotlin plugin
15-
def sourceless = ['kotlinx.coroutines', 'kotlinx-coroutines-bom', 'integration-testing']
16-
def internal = ['kotlinx.coroutines', 'benchmarks', 'integration-testing']
17-
// Not published
18-
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']
12+
apply plugin: 'jdk-convention'
1913

2014
buildscript {
2115
/*
@@ -160,6 +154,8 @@ configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != core
160154
}
161155
}
162156

157+
apply plugin: "bom-conventions"
158+
163159
// Configure subprojects with Kotlin sources
164160
configure(subprojects.findAll { !sourceless.contains(it.name) }) {
165161
// Use atomicfu plugin, it also adds all the necessary dependencies

buildSrc/src/main/kotlin/Projects.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
/*
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
4-
4+
@file:JvmName("Projects")
55
import org.gradle.api.Project
66

77
fun Project.version(target: String): String =
88
property("${target}_version") as String
9+
10+
val coreModule = "kotlinx-coroutines-core"
11+
val testModule = "kotlinx-coroutines-test"
12+
13+
val multiplatform = setOf(coreModule, testModule)
14+
// Not applicable for Kotlin plugin
15+
val sourceless = setOf("kotlinx.coroutines", "kotlinx-coroutines-bom", "integration-testing")
16+
val internal = setOf("kotlinx.coroutines", "benchmarks", "integration-testing")
17+
// Not published
18+
val unpublished = internal + setOf("example-frontend-js", "android-unit-tests")
19+
20+
val Project.isMultiplatform: Boolean get() = name in multiplatform
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
import org.gradle.kotlin.dsl.*
5+
import org.jetbrains.kotlin.gradle.dsl.*
6+
7+
8+
configure(subprojects.filter { it.name !in unpublished }) {
9+
if (name == "kotlinx-coroutines-bom" || name == "kotlinx.coroutines") return@configure
10+
if (isMultiplatform) {
11+
kotlinExtension.sourceSets.getByName("jvmMain").dependencies {
12+
api(project.dependencies.platform(project(":kotlinx-coroutines-bom")))
13+
}
14+
} else {
15+
dependencies {
16+
"api"(platform(project(":kotlinx-coroutines-bom")))
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)