Skip to content

Commit 339a367

Browse files
committed
~ Support build on JDK 1.8 & 11, check for publish under JDK 11
1 parent 7abca62 commit 339a367

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

build.gradle

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44
import org.jetbrains.kotlin.konan.target.HostManager
55

@@ -68,6 +68,7 @@ buildscript {
6868
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
6969
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version"
7070
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
71+
classpath "org.openjfx:javafx-plugin:$javafx_plugin_version"
7172
classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version"
7273

7374
// JMH plugins
@@ -261,8 +262,26 @@ configure(subprojects.findAll { !unpublished.contains(it.name) }) {
261262
// Report Kotlin compiler version when building project
262263
println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
263264

265+
// --------------- Publish only from under JDK11+ ---------------
266+
task checkJdkForPublish {
267+
doFirst {
268+
String javaVersion = System.properties["java.version"]
269+
int i = javaVersion.indexOf('.')
270+
int javaVersionMajor = (i < 0 ? javaVersion : javaVersion.substring(0, i)).toInteger()
271+
if (javaVersionMajor < 11) {
272+
throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${javaVersion}")
273+
}
274+
}
275+
}
276+
264277
// --------------- Configure sub-projects that are published ---------------
265-
task deploy(dependsOn: getTasksByName("publish", true) + getTasksByName("publishNpm", true))
278+
def publishTasks = getTasksByName("publish", true) + getTasksByName("publishNpm", true)
279+
280+
publishTasks.each {
281+
it.dependsOn checkJdkForPublish
282+
}
283+
284+
task deploy(dependsOn: publishTasks)
266285

267286
apply plugin: 'base'
268287

gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ reactor_vesion=3.2.5.RELEASE
1818
reactive_streams_version=1.0.2
1919
rxjava2_version=2.2.8
2020
javafx_version=11.0.2
21+
javafx_plugin_version=0.0.8
2122
binary_compatibility_validator_version=0.1.1
2223

2324
# Android versions

ui/kotlinx-coroutines-javafx/build.gradle

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

5-
plugins {
6-
id 'org.openjfx.javafxplugin' version '0.0.8'
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()
79
}
810

9-
javafx {
10-
version = javafx_version
11-
modules = [ 'javafx.controls' ]
12-
configuration = 'compile'
11+
// 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) {
13+
apply plugin: 'org.openjfx.javafxplugin'
14+
15+
javafx {
16+
version = javafx_version
17+
modules = ['javafx.controls']
18+
configuration = 'compile'
19+
}
1320
}
1421

1522
task checkJdk8() {

0 commit comments

Comments
 (0)