does anyone know of a way to make gradle spit out ...
# scripting
n
does anyone know of a way to make gradle spit out the location of the jdk that is being used ? that would be very helpful for passing it as system property to the scripting stuff
c
org.apache.tools.ant.util.JavaEnvUtils.getJavaHome()
Or directly
System.getProperty("java.home")
Or this, to be on the safe side:
System.getProperty("org.gradle.java.home") ?: System.getProperty("java.home")
n
all of those point to the jre directory, is that always the case ?
but i think this one might be helpful:
org.apache.tools.ant.util.JavaEnvUtils.getJdkExecutable("javac")
s
https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html java.home pointing to the JRE directory is actually expected behavior
I know Gradle tries to change Java Home for compilation like this, something similar might make sense for you. Be forewarned that this can cause issues with different threads in the same JVM if they need to create an SSL context or something, as that references the
java.home
system property to find the
cacerts
file
n
what i do is this:
Copy code
val javac = File(JavaEnvUtils.getJdkExecutable("javac"))
            val jdkHome = javac.parentFile.parentFile
which i can then pass as systemProperty