Currently, the only two ways to specify the location of the GraalVM is through toolchains or environment variables. Both of these ways have various issues.
My preferred solution to this is if the BuildNativeImageTask.graalVMHome was configurable (possibly through the extension as well).
An alternative solution is to allow overriding GRAALVM_HOME in NativeImageExecutableLocator.graalvmHomeProvider via a Gradle property (i.e., the Gradle property would take precedence over it). A Gradle property is much preferable to environment variables, because it is easier to configure, and can be passed as a parameter to a Gradle command (even when running it from somewhere where you can't easily define an environment variable).
The problem with the current possibilities
- Environment variables
- Environment variables are sticky, and you generally have to restart processes (e.g., the IDE) to take effect and this is very inconvenient.
- You can't pass them as a command line argument (in the cases where that is the only thing you can conveniently control).
- Toolchain
- Setting up toolchains requires a place to download and extract GraalVM from (even if it is already installed).
- Even if you set an URL up, Gradle has various limitation for them (e.g., authentication).
- Toolchains are visible to anything needing a JDK, and can influence the build in places were it is not desirable.
Currently, the only two ways to specify the location of the GraalVM is through toolchains or environment variables. Both of these ways have various issues.
My preferred solution to this is if the BuildNativeImageTask.graalVMHome was configurable (possibly through the extension as well).
An alternative solution is to allow overriding
GRAALVM_HOMEin NativeImageExecutableLocator.graalvmHomeProvider via a Gradle property (i.e., the Gradle property would take precedence over it). A Gradle property is much preferable to environment variables, because it is easier to configure, and can be passed as a parameter to a Gradle command (even when running it from somewhere where you can't easily define an environment variable).The problem with the current possibilities