Skip to content

Commit 4794f3c

Browse files
turanskyrecheej
authored andcommitted
Add project JDK convention (Kotlin#1984)
1 parent d709db7 commit 4794f3c

File tree

6 files changed

+25
-29
lines changed

6 files changed

+25
-29
lines changed

build.gradle

+1-14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import org.jetbrains.kotlin.konan.target.HostManager
55

6+
apply plugin: 'jdk-convention'
67
apply from: rootProject.file("gradle/experimental.gradle")
78

89
def rootModule = "kotlinx.coroutines"
@@ -69,7 +70,6 @@ buildscript {
6970
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version"
7071
classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
7172
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
72-
classpath "org.openjfx:javafx-plugin:$javafx_plugin_version"
7373
classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version"
7474

7575
// JMH plugins
@@ -264,22 +264,9 @@ configure(subprojects.findAll { !unpublished.contains(it.name) }) {
264264
// Report Kotlin compiler version when building project
265265
println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
266266

267-
// --------------- Publish only from under JDK11+ ---------------
268-
task checkJdkForPublish {
269-
doFirst {
270-
if (JavaVersionKt.javaVersionMajor < 11) {
271-
throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${JavaVersionKt.javaVersion}")
272-
}
273-
}
274-
}
275-
276267
// --------------- Configure sub-projects that are published ---------------
277268
def publishTasks = getTasksByName("publish", true) + getTasksByName("publishNpm", true)
278269

279-
publishTasks.each {
280-
it.dependsOn checkJdkForPublish
281-
}
282-
283270
task deploy(dependsOn: publishTasks)
284271

285272
apply plugin: 'base'

buildSrc/src/main/kotlin/Idea.kt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Idea {
2+
val active: Boolean
3+
get() = System.getProperty("idea.active") == "true"
4+
}

buildSrc/src/main/kotlin/JavaVersion.kt

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.gradle.api.JavaVersion
2+
3+
if (!JavaVersion.current().isJava11Compatible) {
4+
val message = "Project required JDK 11+, but found ${JavaVersion.current()}"
5+
if (Idea.active) {
6+
logger.error(message)
7+
} else {
8+
throw GradleException(message)
9+
}
10+
}

settings.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
pluginManagement {
66
plugins {
7+
id "org.openjfx.javafxplugin" version javafx_plugin_version
8+
9+
// JMH
710
id "net.ltgt.apt" version "0.21"
811
id "me.champeau.gradle.jmh" version "0.5.0-rc-2"
912
}

ui/kotlinx-coroutines-javafx/build.gradle

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

5-
// JDK11+ does not bundle JavaFx and the plugin for JavaFx support is compiled with class file version 55.0 (JDK 11)
6-
if (JavaVersionKt.javaVersionMajor >= 11) {
7-
apply plugin: 'org.openjfx.javafxplugin'
5+
plugins {
6+
id 'org.openjfx.javafxplugin'
7+
}
88

9-
javafx {
10-
version = javafx_version
11-
modules = ['javafx.controls']
12-
configuration = 'compile'
13-
}
9+
javafx {
10+
version = javafx_version
11+
modules = ['javafx.controls']
12+
configuration = 'compile'
1413
}
1514

1615
task checkJdk8() {

0 commit comments

Comments
 (0)