Skip to content

Instantly share code, notes, and snippets.

@Takhion
Created May 30, 2015 15:44
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save Takhion/5c0f6c0c5aba9db5a488 to your computer and use it in GitHub Desktop.
Save Takhion/5c0f6c0c5aba9db5a488 to your computer and use it in GitHub Desktop.
Automatic Java home (7/8) for Retrolambda with Gradle
String getJavaHome(String version)
{
def stdout = new ByteArrayOutputStream()
exec {
commandLine "/usr/libexec/java_home", "-v", version
standardOutput = stdout;
}
return stdout.toString().trim()
}
retrolambda {
jdk System.getenv("JAVA8_HOME") ?: getJavaHome("1.8")
oldJdk System.getenv("JAVA7_HOME") ?: getJavaHome("1.7")
// ...
}
@sierisimo
Copy link

Wow, this is cool, I didn't know about /usr/libexec/java_home it's pretty awesome.

@alfdev
Copy link

alfdev commented Apr 13, 2016

Oh great!!!!! Thanks Thanks

@Rensodiaz
Copy link

Ty man 👯

@filipesperandio
Copy link

Any ideas of an equivalent for Linux envs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment