From f91129e24cfdb85bee4330ba2034abb83ee37835 Mon Sep 17 00:00:00 2001 From: Ian Young Date: Thu, 5 May 2022 13:53:40 +0100 Subject: [PATCH] Switch to Java 17 Uses the new Java toolchain feature of Gradle to acquire Java 17. Doing it this way means that you can start ./gradlew under any version of Java and still use Java 17 for the build; it picks a candidate from the environment or downloads one if required. It also takes care of source and target compatibility, with the exception of ide.gradle which is handled separately. --- build.gradle | 7 +++++-- ide.gradle | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 44d5845c..9aa0ebeb 100644 --- a/build.gradle +++ b/build.gradle @@ -134,8 +134,11 @@ subprojects { subproject -> apply from: "${rootProject.projectDir}/publish-maven.gradle" - sourceCompatibility=1.8 - targetCompatibility=1.8 + java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } + } [compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:none"] diff --git a/ide.gradle b/ide.gradle index 1778f112..72acc2ee 100644 --- a/ide.gradle +++ b/ide.gradle @@ -4,8 +4,8 @@ import org.gradle.plugins.ide.eclipse.model.SourceFolder apply plugin: "eclipse" eclipse.jdt { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + sourceCompatibility = 17 + targetCompatibility = 17 } // Replace classpath entries with project dependencies (GRADLE-1116)