From 4bb2158cc04a40720d4fb90a76b9f5f6ebca15fd Mon Sep 17 00:00:00 2001 From: David Fairbrother Date: Sun, 5 Mar 2023 16:00:45 +0000 Subject: [PATCH] Use JDK toolchains to explicitly use JDK 17 Explicitly mark that we want version 17 of the JDK as the compiler. Previously we implicitly relied on Gradle getting this right. This means devs and CI will all use the same JDK explicitly rather than implicitly. Pin the target JDK version in build.gradle.kts, this should apply to all targets (including Kotlin) to version 1.8 to maintain compatibility with older devices --- build.gradle.kts | 7 +++++++ buildSrc/build.gradle.kts | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 51c9bf4a4..db501b0b0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ plugins { alias(libs.plugins.detekt) + java } buildscript { @@ -9,6 +10,12 @@ buildscript { } } +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of("17")) + } +} + subprojects { // Configure linting apply() diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index b6413e30c..499880d87 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -2,6 +2,12 @@ plugins { `kotlin-dsl` } +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of("17")) + } +} + repositories { mavenCentral() }