Skip to content

Commit

Permalink
Platform util in 'buildSrc' (#1969)
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky committed May 2, 2020
1 parent 1beebf1 commit de38890
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 1 addition & 10 deletions build.gradle
Expand Up @@ -13,15 +13,6 @@ def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-s
// Not published
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']

static def platformOf(project) {
def name = project.name
if (name.endsWith("-js")) return "js"
if (name.endsWith("-common") || name.endsWith("-native")) {
throw IllegalStateException("$name platform is not supported")
}
return "jvm"
}

buildscript {
/*
* These property group is used to build kotlinx.coroutines against Kotlin compiler snapshot.
Expand Down Expand Up @@ -164,7 +155,7 @@ allprojects {
// Add dependency to core source sets. Core is configured in kx-core/build.gradle
configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != coreModule }) {
evaluationDependsOn(":$coreModule")
def platform = platformOf(it)
def platform = PlatformKt.platformOf(it)
apply from: rootProject.file("gradle/compile-${platform}.gradle")
dependencies {
// See comment below for rationale, it will be replaced with "project" dependency
Expand Down
8 changes: 8 additions & 0 deletions buildSrc/src/main/kotlin/Platform.kt
@@ -0,0 +1,8 @@
import org.gradle.api.Project

fun platformOf(project: Project): String =
when (project.name.substringAfterLast("-")) {
"js" -> "js"
"common", "native" -> throw IllegalStateException("${project.name} platform is not supported")
else -> "jvm"
}

0 comments on commit de38890

Please sign in to comment.