Created
August 23, 2018 12:08
-
-
Save tsamaya/d4c6ab6953f8b32446417bd909bd5acf to your computer and use it in GitHub Desktop.
detectOS with gradle
This file contains hidden or 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; | |
task detect { | |
doLast { | |
println("Groovy/Java says the current OS is " + System.getProperty("os.name")); | |
println("Gradle says the current OS is " + OperatingSystem.current()) | |
println("Is this Linux? " + (OperatingSystem.current().isLinux() ? "Yup" : "Nah")) | |
println("Is this Mac OS X? " + (OperatingSystem.current().isMacOsX() ? "Yup" : "Nah")) | |
println("Is this Windows? " + (OperatingSystem.current().isWindows() ? "Yup" : "Nah")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment