如何获得gradle project.exec或Exec任务以不显示有关命令行的所有信息?
代码
project.exec {
workingDir = exeDir.absolutePath
executable = starter.absolutePath
args = commandLine.split().toList()
environment << envVars
project.logging.captureStandardOutput LogLevel.INFO
standardOutput = outputStream
errorOutput = outputStream
}
输出
Starting process 'command 'regexIdentifier''. Working directory:
/home/code/ Command: /home/code/bin/regexIdentifier server username
password ...
Successfully started process 'command '/home/code/bin/regexIdentifier''
我需要通过gradle Exec任务执行带有密码的cmd,并且希望gradle在执行时不显示命令行
最佳答案
通过覆盖standardOutput和errorOutput流,可以使gradle Exec任务默认情况下不打印输出
standardOutput = new ByteArrayOutputStream()
errorOutput = new ByteArrayOutputStream()
但是,这不会阻止使用--info标志运行时显示命令。