Gradle Exec任务显示密码

时间:2016-06-17 19:37:41

标签: gradle

如何让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在执行时不显示命令行

1 个答案:

答案 0 :(得分:1)

默认情况下,您可以通过覆盖standardOutput和errorOutput流来保持gradle Exec任务不打印输出

standardOutput = new ByteArrayOutputStream()
errorOutput = new ByteArrayOutputStream()

但是,当您使用--info标志运行时,这并不会阻止命令显示。