I am using the Gradle Maven Exec plugin to run a maven build.
How can i make this task use Java 8?
I have configured the use of Java Toolchain. The Gradle build is using Java 11 to produce an application. The Maven build task is to produce a Java Web Start package, and is using Java 8.
Is there a way to make this plugin use Java 8 when invoking Maven?
> Task :createWebstart FAILED
[ERROR] Error executing Maven.
[ERROR] 1 problem was encountered while building the effective toolchains
[FATAL] Non-parseable toolchains /usr/java/jdk1.8.0_181/bin/javac: only whitespace content allowed before start tag and not (position: START_DOCUMENT seen ... @1:1) @ line 1, column 1
That toolchain setting has nothing to do with the Gradle JVM toolchains despite the same naming.
It is some feature of Maven where you can have toolchains in some XML file in the Maven user home directory and that file you can supply there if it is not in the standard location.
I don’t know if that would help with your issue as I avoid Maven whereever possible.
That task does not support Gradle JVM toolchains as far as I can see.
But from a very quick look at the sources of that plugin, it seems to call the mvn executable of the Maven installation. Those executables if I’m not completely mistaken should consider JAVA_HOME environment variable.
So you might have success with setting the JAVA_HOME environment variable to the toolchain installation you want to be used.
Something like this should probably do (untested):