Skip to content

Instantly share code, notes, and snippets.

@tiwiz
Last active June 12, 2018 19:26
Show Gist options
  • Save tiwiz/a2bd1f5249147e017730 to your computer and use it in GitHub Desktop.
Save tiwiz/a2bd1f5249147e017730 to your computer and use it in GitHub Desktop.
How to make Retrolambda work with both Mac OS X and Windows. Thanks to @Takhion - https://gist.github.com/Takhion/5c0f6c0c5aba9db5a488
import org.gradle.internal.os.OperatingSystem;
String getJavaHome(String version) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine "/usr/libexec/java_home", "-v", version
standardOutput = stdout;
}
return stdout.toString().trim()
}
task findOs {
doLast {
if (OperatingSystem.current().isMacOsX()) {
println("Adding retrolmbda")
retrolambda {
jdk System.getenv("JAVA8_HOME") ?: getJavaHome("1.8")
oldJdk System.getenv("JAVA7_HOME") ?: getJavaHome("1.7")
}
}
}
}
preBuild.dependsOn findOs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment