Skip to content

Add project JDK convention #1984

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 3 commits into from
May 12, 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
15 changes: 1 addition & 14 deletions build.gradle
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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