Skip to content

Commit

Permalink
Add project JDK convention (#1984)
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky committed May 12, 2020
1 parent 10acaf2 commit e47cb35
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
15 changes: 1 addition & 14 deletions build.gradle
Expand Up @@ -3,6 +3,7 @@
*/
import org.jetbrains.kotlin.konan.target.HostManager

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

def rootModule = "kotlinx.coroutines"
Expand Down Expand Up @@ -69,7 +70,6 @@ buildscript {
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version"
classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
classpath "org.openjfx:javafx-plugin:$javafx_plugin_version"
classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version"

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

// --------------- Publish only from under JDK11+ ---------------
task checkJdkForPublish {
doFirst {
if (JavaVersionKt.javaVersionMajor < 11) {
throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${JavaVersionKt.javaVersion}")
}
}
}

// --------------- Configure sub-projects that are published ---------------
def publishTasks = getTasksByName("publish", true) + getTasksByName("publishNpm", true)

publishTasks.each {
it.dependsOn checkJdkForPublish
}

task deploy(dependsOn: publishTasks)

apply plugin: 'base'
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/Idea.kt
@@ -0,0 +1,4 @@
object Idea {
val active: Boolean
get() = System.getProperty("idea.active") == "true"
}
7 changes: 0 additions & 7 deletions buildSrc/src/main/kotlin/JavaVersion.kt

This file was deleted.

10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/jdk-convention.gradle.kts
@@ -0,0 +1,10 @@
import org.gradle.api.JavaVersion

if (!JavaVersion.current().isJava11Compatible) {
val message = "Project required JDK 11+, but found ${JavaVersion.current()}"
if (Idea.active) {
logger.error(message)
} else {
throw GradleException(message)
}
}
3 changes: 3 additions & 0 deletions settings.gradle
Expand Up @@ -4,6 +4,9 @@

pluginManagement {
plugins {
id "org.openjfx.javafxplugin" version javafx_plugin_version

// JMH
id "net.ltgt.apt" version "0.21"
id "me.champeau.gradle.jmh" version "0.5.0-rc-2"
}
Expand Down
15 changes: 7 additions & 8 deletions ui/kotlinx-coroutines-javafx/build.gradle
Expand Up @@ -2,15 +2,14 @@
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

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

javafx {
version = javafx_version
modules = ['javafx.controls']
configuration = 'compile'
}
javafx {
version = javafx_version
modules = ['javafx.controls']
configuration = 'compile'
}

task checkJdk8() {
Expand Down

0 comments on commit e47cb35

Please sign in to comment.