Skip to content

Instantly share code, notes, and snippets.

@xconnecting
Created January 24, 2013 00:29
Show Gist options
  • Save xconnecting/4616290 to your computer and use it in GitHub Desktop.
Save xconnecting/4616290 to your computer and use it in GitHub Desktop.
Gradle: Get standard output text
ant.condition(property: "os", value: "windows") { os(family: "windows") }
ant.condition(property: "os", value: "unix" ) { os(family: "unix") }
task execCommandLine(type:Exec) {
switch(ant.properties.os){
case 'windows':
commandLine 'cmd', '/c', 'echo', 'hello'
break
case 'unix':
commandLine 'echo', 'hello'
break
}
standardOutput = new ByteArrayOutputStream()
}
execCommandLine.doFirst {
println 'doFirst'
print standardOutput.toString()
}
execCommandLine << {
println 'doLast'
print standardOutput.toString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment