Skip to content

Commit a8f4b64

Browse files
authored
Common java version method (#1965)
1 parent 5b00e48 commit a8f4b64

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

build.gradle

+3-6
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ if (build_snapshot_train) {
227227
* but publishing plugin does not re-read artifact names for kotlin-jvm projects, so renaming is not applied in pom files
228228
* for JVM-only projects.
229229
*
230-
* We artificially replace "project" dependency with "module" one to have proper names in pom files, but then substitute it
230+
* We artificially replace "project" dependency with "module" one to have proper names in pom files, but then substitute it
231231
* to have out "project" dependency back.
232232
*/
233233
configure(subprojects.findAll { it.name != coreModule && it.name != rootModule }) {
@@ -278,11 +278,8 @@ println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompi
278278
// --------------- Publish only from under JDK11+ ---------------
279279
task checkJdkForPublish {
280280
doFirst {
281-
String javaVersion = System.properties["java.version"]
282-
int i = javaVersion.indexOf('.')
283-
int javaVersionMajor = (i < 0 ? javaVersion : javaVersion.substring(0, i)).toInteger()
284-
if (javaVersionMajor < 11) {
285-
throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${javaVersion}")
281+
if (JavaVersionKt.javaVersionMajor < 11) {
282+
throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${JavaVersionKt.javaVersion}")
286283
}
287284
}
288285
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
val javaVersion: String
2+
get() = System.getProperty("java.version")!!
3+
4+
val javaVersionMajor: Int
5+
get() = javaVersion
6+
.substringBefore(".")
7+
.toInt()

ui/kotlinx-coroutines-javafx/build.gradle

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
static int javaVersionMajor() {
6-
String javaVersion = System.properties["java.version"]
7-
int i = javaVersion.indexOf('.')
8-
return (i < 0 ? javaVersion : javaVersion.substring(0, i)).toInteger()
9-
}
10-
115
// JDK11+ does not bundle JavaFx and the plugin for JavaFx support is compiled with class file version 55.0 (JDK 11)
12-
if (javaVersionMajor() >= 11) {
6+
if (JavaVersionKt.javaVersionMajor >= 11) {
137
apply plugin: 'org.openjfx.javafxplugin'
14-
8+
159
javafx {
1610
version = javafx_version
1711
modules = ['javafx.controls']

0 commit comments

Comments
 (0)