【问题标题】:Gradle Exec task shows passwordGradle Exec 任务显示密码
【发布时间】:2016-06-17 19:37:40
【问题描述】:

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

【问题讨论】:

    标签: gradle


    【解决方案1】:

    您可以通过覆盖 standardOutput 和 errorOutput 流来阻止 gradle Exec 任务默认打印输出

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-13
      • 1970-01-01
      • 2013-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-28
      • 2012-12-05
      相关资源
      最近更新 更多