We currently use Gradle toolchains to set the Java version, since this is the recommended approach in Gradle 8. We could also use Gradle toolchains to set the vendor, if we desired and it would be complimentary to sdkmanrc with the following benefits:
does not require sdkman, but is compatible with sdkman installed JDKs
automatic download, only when the jdk is missing from all of the normal locations, including sdkman
works with every project using Gradle
settings.gradle (yes it only works there), after any pluginManagment block and not in it. This provides automatic download for all common jdks, versions and operating systems.
plugins {
id "org.gradle.toolchains.foojay-resolver-convention" version "0.8.0"
}
without foojay-resolver-convention the build will fail, if a JDK meeting the languageVersion and vendor settings is not present.
There will be a false error message the first run, after download, but it runs fine and is gone the next time.
Invalid Java installation found at ...
jdks live in .gradle/jdks in user home
https://docs.gradle.org/current/userguide/toolchains.html#sec:auto_detection
By default, Gradle automatically detects local JRE/JDK installations so no further configuration is required by the user. The following is a list of common package managers, tools, and locations that are supported by the JVM auto-detection.
JVM auto-detection knows how to work with:
Operation-system specific locations: Linux, macOS, Windows
Issue description
We currently use Gradle toolchains to set the Java version, since this is the recommended approach in Gradle 8. We could also use Gradle toolchains to set the vendor, if we desired and it would be complimentary to sdkmanrc with the following benefits:
settings.gradle
(yes it only works there), after anypluginManagment
block and not in it. This provides automatic download for all common jdks, versions and operating systems.without foojay-resolver-convention the build will fail, if a JDK meeting the languageVersion and vendor settings is not present.
then in
build.gradle
:There will be a false error message the first run, after download, but it runs fine and is gone the next time. Invalid Java installation found at ...
jdks live in .gradle/jdks in user home
https://docs.gradle.org/current/userguide/toolchains.html#sec:auto_detection By default, Gradle automatically detects local JRE/JDK installations so no further configuration is required by the user. The following is a list of common package managers, tools, and locations that are supported by the JVM auto-detection. JVM auto-detection knows how to work with: