Skip to content

Instantly share code, notes, and snippets.

@skyfe79
Forked from Takhion/build.gradle
Created June 8, 2016 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyfe79/ffc58dd9956c878784d1db46e0b23548 to your computer and use it in GitHub Desktop.
Save skyfe79/ffc58dd9956c878784d1db46e0b23548 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")
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment