Skip to content

Platform util in 'buildSrc' #1969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions build.gradle
Original file line number Diff line number Diff line change
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 @@ -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
Expand Down
8 changes: 8 additions & 0 deletions buildSrc/src/main/kotlin/Platform.kt
Original file line number Diff line number Diff line change
@@ -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"
}