Suppressing interactive output in Gradle exec tasks

Some Gradle Exec tasks produce excessive output when the command updates text in place.

When run from a terminal, these commands produce a couple of lines of output that are updated in place.

  • How can I change docker image configurations?
  • Docker and Cloudera Quick start: How to run own jar-file?
  • How can a Docker Container get host's system information(df, ps)?
  • Docker named volumes vs DOC (data-only-containers)
  • Docker try to download unnecessary busybox image on creation of redis pod with kubernetes tools
  • Docker not starting “ could not delete the default bridge network: network bridge has active endpoints”"
  • When run from within Gradle, they produce a new line of output each time something is updated, e.g.:

    docker build:

    task dockerBuild(type: Exec) {
        commandLine 'docker', 'build', '-t', 'foo', '.'
    }
    

    when run produces:

    Sending build context to Docker daemon 557.1 kB
    Sending build context to Docker daemon 1.114 MB
    Sending build context to Docker daemon 1.646 MB
    Sending build context to Docker daemon  2.17 MB
    Sending build context to Docker daemon  2.72 MB
    Sending build context to Docker daemon 3.277 MB
    Sending build context to Docker daemon 3.834 MB
    Sending build context to Docker daemon 4.391 MB
    ... hundreds more lines ...
    

    wget:

    task fetchData(type: Exec) {
        commandLine 'wget', 'http://example.org/some/large/file'
    }
    

    when run outputs:

    HTTP request sent, awaiting response... 200 OK
    Length: 209715200 (200M) [application/zip]
    Saving to: '200MB.zip'
    
      0K .......... .......... .......... .......... ..........  0% 5.02M 40s
     50K .......... .......... .......... .......... ..........  0% 6.34M 36s
    100K .......... .......... .......... .......... ..........  0% 6.68M 34s
    150K .......... .......... .......... .......... ..........  0% 6.42M 33s
    200K .......... .......... .......... .......... ..........  0% 6.41M 33s
    250K .......... .......... .......... .......... ..........  0% 7.12M 32s
    ... thousands more lines ...
    

    Is this anything I can fix from within Gradle (e.g. ask it to execute commands in non-interactive mode), or is it down to individual applications to provide flags for disabling this sort of output?

  • Will docker cost system resources to exchange data with system?
  • Route over docker bridge network to docker overlay network
  • Class 'MongoId' not found in Laradock application
  • Can docker log to multiple gelf destinations
  • PHP websites with Docker
  • How to make docker container be notified when volume from another container was updated?
  • One Solution collect form web for “Suppressing interactive output in Gradle exec tasks”

    From Exec DSL documentation, you can redirect the output of the executable to your own stream.

    //store the output instead of printing to the console:
    standardOutput = new ByteArrayOutputStream()
    

    You could optionally also redirect error stream to keep it completely quiet, but by leaving it intact, you’ll see any exit errors in gradle log.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.