-
Notifications
You must be signed in to change notification settings - Fork 685
Improve Gradle Java support #4218
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1e773cc
to
f46b73d
Compare
- Use Java toolchains to run and compile the build. - Add Foojay toolchain resolver, that will automatically download the required toolchains. - Use Java 21 to run Gradle and compile the code. - Set the minimum supported Java version to 8. - Set the maximum supported Java version to 21. - Create a new test task to run the tests with Java 21. - Fix code to support Java 8.
499a8fb
to
11c9ff5
Compare
aSemy
commented
Jul 28, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file are mostly tidying of the opt-in flags, but I also moved the JVM-specific compilation flags to kotest-jvm-conventions.gradle.kts
aSemy
commented
Jul 28, 2024
sksamuel
approved these changes
Jul 28, 2024
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 3, 2024
To maximise Gradle cache hits, and to use the best Gradle features, use Java 21 to run Gradle builds. Gradle has a new feature for running the Gradle Daemon with a fixed Java version. This can be configured to run automatically. Currently Gradle does not auto-provision the necessary Java version, but hopefully this will be available in Gradle 8.10. This PR should be merged after #4218, which will ensure that a stable JDK is used for compilation and running tests. --------- Co-authored-by: Sam <sam@sksamuel.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Kotest is supposed to support Java 8, but there are a couple of places in the code that use Java utils that require 9+. This can be resolved by testing using a fixed Java Toolchain to always test using Java 8.
The JDK used to compile Kotest can also be fixed. Using newer JDKs is advantageous because of improved compilation performance and fixes. The Java compiler can be configured to emit classes compatible with Java 8 with the
-release
flag. (Kotlin has an analogous-Xjdk-release
flag.)To ensure compatibility going forward, I registered a new test run for launching the JVM tests with the maximum supported JDK. This will run automatically.
Using fixed Java Toolchains for compilation and running tests improves build performance, cacheability, and stability.
Usage
The Java versions used to compile, run, and test Kotest can be configured in
libs.versions.toml
kotest/gradle/libs.versions.toml
Lines 25 to 31 in c8666f1
To test Java 8, run
./gradlew jvmTest
. To test Java 21, run./gradlew jvmMaxJdkTest
.Summary