rossturner / king-under-the-mountain

A simulation-based strategy game written in Java using LibGDX
MIT License
111 stars 17 forks source link

Configure Gradle to always use JDK 17 toolchain. #21

Closed nanodeath closed 4 months ago

nanodeath commented 4 months ago

This is another ergonomics change to make it easier for new users to get started without having a specific version of the JDK installed -- so long as they have a version that can run Gradle, the necessary JVM will automatically download.

This change enables you to use Java 11 or 21 or whatever globally, while the game compiles and runs (during development anyway) with the given distribution. I think later versions of Gradle 7 have improvements for JVM toolchains, but it works fine for me. I also removed the sourceCompatibility parameter because the build fails otherwise.

Toolchains are documented here: https://docs.gradle.org/7.6.2/userguide/toolchains.html

Builds still work from IntelliJ or from the terminal. There's no impact on build performance that I can see. Originally I specified the AdoptOpenJdk vendor per your readme, but at least in Gradle 7.2, this causes Gradle to unpack the downloaded distribution every build, which adds 4 seconds of needless wait time, so I left that out.