Skip to content

Instantly share code, notes, and snippets.

@EJunWhite
Last active January 24, 2019 01:15
Show Gist options
  • Save EJunWhite/c2d92ddcd7fc9cf39f1aeb6e3737722b to your computer and use it in GitHub Desktop.
Save EJunWhite/c2d92ddcd7fc9cf39f1aeb6e3737722b to your computer and use it in GitHub Desktop.
Check os
def getOsName(project) {
final String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("linux")) {
return ("linux");
} else if (osName.contains("mac os x") || osName.contains("darwin") || osName.contains("osx")) {
return ("macos");
} else if (osName.contains("windows")) {
return ("windows");
} else if (osName.contains("sunos") || osName.contains("solaris")) {
return ("solaris");
} else if (osName.contains("freebsd")) {
return ("freebsd");
}
return ("unix");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment