From 2d46cb4bc9e8d8dac19abf8a1703c7c9167805f9 Mon Sep 17 00:00:00 2001 From: Victor Turansky Date: Tue, 28 Apr 2020 21:15:01 +0300 Subject: [PATCH] Platform util in 'buildSrc' --- build.gradle | 11 +---------- buildSrc/src/main/kotlin/Platform.kt | 8 ++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 buildSrc/src/main/kotlin/Platform.kt diff --git a/build.gradle b/build.gradle index 08a241a411..dd6ff4de9b 100644 --- a/build.gradle +++ b/build.gradle @@ -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. @@ -166,7 +157,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 diff --git a/buildSrc/src/main/kotlin/Platform.kt b/buildSrc/src/main/kotlin/Platform.kt new file mode 100644 index 0000000000..4cacd9e026 --- /dev/null +++ b/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" + }