Skip to content

Commit

Permalink
Common java version method (#1965)
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky authored Apr 28, 2020
1 parent 5b00e48 commit a8f4b64
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
9 changes: 3 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ if (build_snapshot_train) {
* 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 }) {
Expand Down Expand Up @@ -278,11 +278,8 @@ println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompi
// --------------- 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}")
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions buildSrc/src/main/kotlin/JavaVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
val javaVersion: String
get() = System.getProperty("java.version")!!

val javaVersionMajor: Int
get() = javaVersion
.substringBefore(".")
.toInt()
10 changes: 2 additions & 8 deletions ui/kotlinx-coroutines-javafx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit a8f4b64

Please # to comment.