Common java version method (#1965)

diff --git a/build.gradle b/build.gradle
index c679109..08a241a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -227,7 +227,7 @@
  * but publishing plugin does not re-read artifact names for kotlin-jvm projects, so renaming is not applied in pom files
  * for JVM-only projects.
  *
- * We artificially replace "project" dependency with "module" one to have proper names in pom files, but then substitute it 
+ * We artificially replace "project" dependency with "module" one to have proper names in pom files, but then substitute it
  * to have out "project" dependency back.
  */
 configure(subprojects.findAll { it.name != coreModule && it.name != rootModule }) {
@@ -278,11 +278,8 @@
 // --------------- Publish only from under JDK11+ ---------------
 task checkJdkForPublish {
     doFirst {
-        String javaVersion = System.properties["java.version"]
-        int i = javaVersion.indexOf('.')
-        int javaVersionMajor =  (i < 0 ? javaVersion : javaVersion.substring(0, i)).toInteger()
-        if (javaVersionMajor < 11) {
-            throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${javaVersion}")
+        if (JavaVersionKt.javaVersionMajor < 11) {
+            throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${JavaVersionKt.javaVersion}")
         }
     }
 }
diff --git a/buildSrc/src/main/kotlin/JavaVersion.kt b/buildSrc/src/main/kotlin/JavaVersion.kt
new file mode 100644
index 0000000..2fbefce
--- /dev/null
+++ b/buildSrc/src/main/kotlin/JavaVersion.kt
@@ -0,0 +1,7 @@
+val javaVersion: String
+    get() = System.getProperty("java.version")!!
+
+val javaVersionMajor: Int
+    get() = javaVersion
+        .substringBefore(".")
+        .toInt()
diff --git a/ui/kotlinx-coroutines-javafx/build.gradle b/ui/kotlinx-coroutines-javafx/build.gradle
index 9d1c128..daabda4 100644
--- a/ui/kotlinx-coroutines-javafx/build.gradle
+++ b/ui/kotlinx-coroutines-javafx/build.gradle
@@ -2,16 +2,10 @@
  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
  */
 
-static int javaVersionMajor() {
-    String javaVersion = System.properties["java.version"]
-    int i = javaVersion.indexOf('.')
-    return (i < 0 ? javaVersion : javaVersion.substring(0, i)).toInteger()
-}
-
 // JDK11+ does not bundle JavaFx and the plugin for JavaFx support is compiled with class file version 55.0 (JDK 11)
-if (javaVersionMajor() >= 11) {
+if (JavaVersionKt.javaVersionMajor >= 11) {
     apply plugin: 'org.openjfx.javafxplugin'
-    
+
     javafx {
         version = javafx_version
         modules = ['javafx.controls']