grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.78k stars 950 forks source link

Grails 7: Consider Gradle Java Toolchain to set Vendor in addition to sdkmanrc files #13783

Open jamesfredley opened 5 days ago

jamesfredley commented 5 days ago

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 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.

then in build.gradle:

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
        vendor = JvmVendorSpec.BELLSOFT
    }
}

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:

jamesfredley commented 4 days ago

Need to understand how this works with matix.java in github actions.