Skip to content

Commit a9232c5

Browse files
turanskyrecheej
authored andcommitted
Platform util in 'buildSrc' (Kotlin#1969)
1 parent 80f417e commit a9232c5

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

build.gradle

+1-10
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-s
1313
// Not published
1414
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']
1515

16-
static def platformOf(project) {
17-
def name = project.name
18-
if (name.endsWith("-js")) return "js"
19-
if (name.endsWith("-common") || name.endsWith("-native")) {
20-
throw IllegalStateException("$name platform is not supported")
21-
}
22-
return "jvm"
23-
}
24-
2516
buildscript {
2617
/*
2718
* These property group is used to build kotlinx.coroutines against Kotlin compiler snapshot.
@@ -164,7 +155,7 @@ allprojects {
164155
// Add dependency to core source sets. Core is configured in kx-core/build.gradle
165156
configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != coreModule }) {
166157
evaluationDependsOn(":$coreModule")
167-
def platform = platformOf(it)
158+
def platform = PlatformKt.platformOf(it)
168159
apply from: rootProject.file("gradle/compile-${platform}.gradle")
169160
dependencies {
170161
// See comment below for rationale, it will be replaced with "project" dependency

buildSrc/src/main/kotlin/Platform.kt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import org.gradle.api.Project
2+
3+
fun platformOf(project: Project): String =
4+
when (project.name.substringAfterLast("-")) {
5+
"js" -> "js"
6+
"common", "native" -> throw IllegalStateException("${project.name} platform is not supported")
7+
else -> "jvm"
8+
}

0 commit comments

Comments
 (0)