From 5e3393093bd73c15081be5dd8293d97f1a9bd6a7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 11 Apr 2021 16:53:44 +0200 Subject: [PATCH] Fix build.gradle with windows --- build.gradle | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4f62589..2fb8f9d 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,8 @@ * along with this program. If not, see . */ +import org.apache.tools.ant.taskdefs.condition.Os + plugins { // Adding the base plugin fixes the following gradle warnings in IntelliJ: // @@ -40,6 +42,12 @@ ext { uberJarName = "${artifact}-all.jar" jarName = "${artifact}.jar" libs = "${buildDir}/libs" + + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + operatingSystem = "windows" + } else { + operatingSystem = "unix" + } } compileJava.options.encoding = 'UTF-8' @@ -105,7 +113,12 @@ if (project.hasProperty("hostname")) { * @return the trimmed result from stdout, stderr and the exit value */ def shell(String command) { - def proc = ['bash', '-c', command].execute() + def proc + if (operatingSystem == "unix") { + proc = ['bash', '-c', command].execute() + } else { + proc = ["cmd", "/c", command].execute() + } def out = new StringBuilder() def err = new StringBuilder() proc.waitForProcessOutput(out, err)