Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Ortiz committed Feb 7, 2018
1 parent 63bde18 commit e9abad3
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,10 @@ task selftest {
if (isWin) {
selftestScript+=".bat"
}else {
selftestScript+=".sh"
selftestScript = "./"+selftestScript+".sh"
}
def array = commandLinePrefix + [selftestScript]
println array
executeProcess(array, "./src/test-suite")
executeProcess(array, "./src/test-suite", true)
}
}

Expand Down Expand Up @@ -667,11 +666,19 @@ def deployBinary(deployable, env) {
def executeProcess(command, workingDir, printOutputUntilFinish = false) {
ProcessBuilder pb = new ProcessBuilder(command)
pb.directory(new File(workingDir))
pb.redirectError(ProcessBuilder.Redirect.PIPE)
pb.redirectOutput(ProcessBuilder.Redirect.PIPE)
if (!printOutputUntilFinish) {
pb.redirectError(ProcessBuilder.Redirect.PIPE)
pb.redirectOutput(ProcessBuilder.Redirect.PIPE)
}
pb.redirectErrorStream(true)
Process proc = pb.start();
if (!silentBuild) {
Runtime.getRuntime().addShutdownHook({
if(proc.alive) {
println "Killing Process ${command} on dir ${workingDir}"
proc.destroy()
}
})
if (!silentBuild && !printOutputUntilFinish) {
watchProcessOutput(proc, null)
}
proc.waitFor()
Expand All @@ -680,6 +687,7 @@ def executeProcess(command, workingDir, printOutputUntilFinish = false) {
}
}


// Poor's man tail (but get's the job done)
def watchProcessOutput(process, processOutputFile) {
def processInput = process.getInputStream()
Expand All @@ -690,7 +698,7 @@ def watchProcessOutput(process, processOutputFile) {
if (bufferedReader.ready()) {
def line = null
while ((line = bufferedReader.readLine()) != null) {
logger.lifecycle line
println line
}
}
}
Expand Down

0 comments on commit e9abad3

Please sign in to comment.