We are building various product that use different version of JAVA: Some legacy are using 1.8, current projects are using 1.8 and new projects are starting to use 11.
However, I'm having error. Some Maven project use the fork parameter due to their size. But Maven is using the JAVA_HOME, NOT the parent process, to determine which JDK to use for the forked process.
The build agent are started with JAVA_HOME set to Java 1.8
When an agent start a Java 11 build, maven start with the correct JDK. But when time come to fork, it inherit the agent's JAVA home and crash with the following error:
[Compiler] Compilation failure javac: invalid flag: --release Usage: javac <options> <source files> use -help for a list of possible options
I cannot simply start the agent with Java 11, as I'll get class not found when compiling Java 1.8 code due to the removal of JAVA EE.
Is there a way to have the agent use the selected JDK's home as the JAVA_HOME rather then inherit the agent's JAVA_HOME without editing every single build definition?