Native Image Agent Uses `JAVA_HOME` Instead of `GRAALVM_HOME`
Is your feature request related to a problem? Please describe.
When running gradle -Pagent clean test agent picks JAVA_HOME even though GRAALVM_HOME is set. The problem is that we can set JAVA_HOME to some earlier version (lets say JDK17) and GRAALVM_HOME to the later one (e.g. JDK21), and therefor agent will generate metadata with one JDK version while the Native Image will be created with the different one (example where different metadata can be generated with different Java versions).
Describe the solution you'd like
Make native-image-agent use GRAALVM_HOME as default if possible. Only if GRAALVM_HOME is not configured, use JAVA_HOME.
Describe alternatives you've considered
At least mention in the documentation that agent uses JAVA_HOME
I am having the same issue and before finding and reading this issue I had the exact same expectation.
I would consider this as a bug that this plugin is based on JAVA_HOME rather than GRAALVM_HOME.
Even if both would share the same version there are several edge-cases where GraalVM and regular JVM (OpenJDK) do not behave the same and the maven build will fail, if you make JAVA_HOME point to GraalVM.
I want to use regular OpenJDK for Maven and for the native-maven-plugin I want to use GraalVM to build the native image.
There currently seems no way to configure this for this plugin except maybe for using the docker based approach.