Created
August 9, 2019 06:46
-
-
Save h-mochizuki/1d76372658f015b6408f17a65df747d0 to your computer and use it in GitHub Desktop.
gradleでコマンドラインでの実行をしたい場合の処理
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.apache.tools.ant.taskdefs.condition.Os | |
String cmdLine(String cmd, Writer out = new StringWriter(), Writer err = new StringWriter()) { | |
(Os.isFamily(Os.FAMILY_WINDOWS) ? "cmd /c ${cmd}" : cmd).execute().waitForProcessOutput(out, err) | |
assert err.toString().trim().size() == 0: "$err" | |
out.toString() | |
} | |
task hello << { | |
cmdLine("echo hello") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment