Skip to content
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

feat(build): fail if Gradle is started with Java 20 or older #12780

Merged
merged 4 commits into from
Apr 19, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,26 @@ plugins {
version =
providers.fileContents(rootProject.layout.projectDirectory.versionTxt()).asText.get().trim()

// Fail the build if Gradle is started with an old version of Java
val MIN_JAVA_VERSION = JavaVersion.VERSION_21
val CUR_JAVA_VERSION = JavaVersion.current()

if (CUR_JAVA_VERSION.ordinal < MIN_JAVA_VERSION.ordinal) {
throw StopExecutionException(
"ERROR: Gradle is started with Java " +
CUR_JAVA_VERSION +
". This project requires running Gradle with Java " +
MIN_JAVA_VERSION +
" or above." +
" Please check your JAVA_HOME and/or PATH and configure the default JDK to use Java version " +
MIN_JAVA_VERSION +
" or above."
)
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = MIN_JAVA_VERSION
targetCompatibility = MIN_JAVA_VERSION

toolchain {
languageVersion = JavaLanguageVersion.of(21)
Expand Down
Loading