Last active
June 12, 2018 19:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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