I need every project to be able to use a different version of Java. Since developers in our team all installed different versions of Java in various directories, we have an environment variable JAVA_HOME_1_8 which abstracts this out.
The last thing that’s left to do is to set org.gradle.java.home in gradle.properties to JAVA_HOME_1_8 environment variable.
I tried: org.gradle.java.home="${System.env.JAVA_HOME_1_8}" with many variations (with or wo quotation marks, same for $, etc.)
We have similar variables, but JAVA8_HOME and so on.
We just adjusted the gradlew scripts to use these instead of JAVA_HOME.
Nowadays I would simply use Java Toolchains feature though.
The changes depend on what you want.
By default the wrappers search in JAVA_HOME if set and search in PATH if no set.
For our build we wanted to force using JAVA8_HOME, so we also removed the search in PATH and enforce JAVA8_HOME being set.
Your requirements might be different.
Also instead of manipulating the wrapper, as you have to redo this on every wrapper generation, you could also have a wrapper-wrapper that sets JAVA_HOME to the value of your variable and then calls the actual wrapper script, then is the script your colleagues have to call.
That is exactly what I seem to be unable to do! If you look at the original post I was saying that I can’t set org.gradle.java.home to an environment variable. In this case is JAVA_HOME_1_8 but could be anything.
Didn’t I just tell you that my name is not Bjorn? >:-(
That is exactly what I seem to be unable to do! If you look at the original post I was saying that I can’t set org.gradle.java.home to an environment variable.
And that is not the least what I suggested.
I said create a wrapper-wrapper that sets JAVA_HOME to JAVA_HOME_1_8 and then calls the real wrapper.