Context
I'm upgrading the version of Java from 8 to 17 in a repository that depends on a library. I want to build the repository with Java 17, but the library with Java 8 because it cannot be built with Java 8.
Environment
Docker container with Java 17, but also with Java 8.
Question
The repository builds the library by running ant tasks in that library
<ant dir="${lib-build-top}" target="all"/>
<ant dir="${lib-build-top}" target="buildjars"/>
In the terminal the library can be built with
JAVA_HOME=path/to/jdk8 ant
So I want to be able to do something like
set JAVA_HOME and java.home from jdk17 to jdk8
<ant dir="${lib-build-top}" target="all"/>
<ant dir="${lib-build-top}" target="buildjars"/>
change JAVA_HOME and java.home back to jdk17
How can I do that?