Skip to content

Commit

Permalink
Introduce coroutines platform to have all the dependencies aligned (K…
Browse files Browse the repository at this point in the history
…otlin#2952)

* Introduce coroutines platform to have all the dependencies aligned

Fixes Kotlin#2865
  • Loading branch information
qwwdfsad authored and yorickhenning committed Jan 28, 2022
1 parent 103e3d5 commit eb9a33c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
14 changes: 5 additions & 9 deletions build.gradle
Expand Up @@ -2,20 +2,14 @@
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/


import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.dokka.gradle.DokkaTaskPartial

apply plugin: 'jdk-convention'
import static Projects.*

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

buildscript {
/*
Expand Down Expand Up @@ -160,6 +154,8 @@ configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != core
}
}

apply plugin: "bom-conventions"

// Configure subprojects with Kotlin sources
configure(subprojects.findAll { !sourceless.contains(it.name) }) {
// Use atomicfu plugin, it also adds all the necessary dependencies
Expand Down
14 changes: 13 additions & 1 deletion buildSrc/src/main/kotlin/Projects.kt
@@ -1,8 +1,20 @@
/*
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:JvmName("Projects")
import org.gradle.api.Project

fun Project.version(target: String): String =
property("${target}_version") as String

val coreModule = "kotlinx-coroutines-core"
val testModule = "kotlinx-coroutines-test"

val multiplatform = setOf(coreModule, testModule)
// Not applicable for Kotlin plugin
val sourceless = setOf("kotlinx.coroutines", "kotlinx-coroutines-bom", "integration-testing")
val internal = setOf("kotlinx.coroutines", "benchmarks", "integration-testing")
// Not published
val unpublished = internal + setOf("example-frontend-js", "android-unit-tests")

val Project.isMultiplatform: Boolean get() = name in multiplatform
19 changes: 19 additions & 0 deletions buildSrc/src/main/kotlin/bom-conventions.gradle.kts
@@ -0,0 +1,19 @@
/*
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.*


configure(subprojects.filter { it.name !in unpublished }) {
if (name == "kotlinx-coroutines-bom" || name == "kotlinx.coroutines") return@configure
if (isMultiplatform) {
kotlinExtension.sourceSets.getByName("jvmMain").dependencies {
api(project.dependencies.platform(project(":kotlinx-coroutines-bom")))
}
} else {
dependencies {
"api"(platform(project(":kotlinx-coroutines-bom")))
}
}
}

0 comments on commit eb9a33c

Please sign in to comment.