Platform util in 'buildSrc' (#1969)

diff --git a/build.gradle b/build.gradle
index af33d38..032c4e7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -13,15 +13,6 @@
 // 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.
@@ -164,7 +155,7 @@
 // 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 0000000..4cacd9e
--- /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"
+    }