providers.exec
)。
为了将stdin和stdout合并到一个流中,我使用了以下方法:
ByteArrayOutputStream().use {
val execResult = exec {
commandLine(*args)
isIgnoreExitValue = true
standardOutput = it // <----
errorOutput = it // <----
}
return CommandExecutionResult(exitCode = execResult.exitValue, consoleOutput = it.toString())
}
不幸的是,这与
providers.exec
API无法使用。 相同的尝试重定向输出投掷“不能为执行输出提供商配置
标准流”:
ByteArrayOutputStream().use { outputStream ->
val execResult = providers.exec {
commandLine(*args)
isIgnoreExitValue = true
standardOutput = outputStream
errorOutput = outputStream
}
return CommandExecutionResult(exitCode = execResult.result.get().exitValue, consoleOutput = outputStream.toString())
}
如何从providers.exec
?
可以在github问题下方找到修复它的方法