Skip to content

Common java version method #1965

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
Apr 28, 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
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