in plugin-bazel-event-service/src/main/kotlin/bazel/BazelRunner.kt [60:97]
fun run(): Result {
val commandLine = args.joinToString(" ") { if (it.contains(' ')) "\"$it\"" else it }
messageWriter.message("Starting: $commandLine")
messageWriter.message("in directory: $workingDirectory")
val process =
ProcessBuilder(args.toList())
.directory(workingDirectory)
.start()
val errors = mutableListOf<String>()
val stdOutReader =
ActiveReader(process.inputStream.bufferedReader()) { line ->
if (verbosity.atLeast(Verbosity.Diagnostic)) {
// this message is printed by bazel itself, we will get the same message from BES/Binary log file
// logging it as trace to reduce noise in the build log
messageWriter.trace(line)
}
}
val stdErrReader =
ActiveReader(process.errorStream.bufferedReader()) { line ->
if (line.startsWith("ERROR:") || line.startsWith("FATAL:")) {
errors.add(line)
}
if (verbosity.atLeast(Verbosity.Diagnostic)) {
messageWriter.trace(line)
}
}
stdOutReader.thread.join()
stdErrReader.thread.join()
process.waitFor()
val exitCode = process.exitValue()
return Result(exitCode, errors)
}