From 9f29af10be458c524c8e790fb1bde1a6b757d7f1 Mon Sep 17 00:00:00 2001 From: skullmaggots Date: Wed, 27 Aug 2014 16:43:45 +0100 Subject: [PATCH 1/2] Display docker command line output. This also ensures the process output buffer does not get full and hang the process.waitFor() blocking call for large docker builds. --- gradle.properties | 2 +- .../plugins/docker/client/NativeDockerClient.groovy | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index ed57e3c..9a6a1f0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=se.transmode.gradle -version=1.2 +version=1.2.1 # use gradle daemon by default org.gradle.daemon = true diff --git a/src/main/groovy/se/transmode/gradle/plugins/docker/client/NativeDockerClient.groovy b/src/main/groovy/se/transmode/gradle/plugins/docker/client/NativeDockerClient.groovy index fa20aa7..e7c6b15 100644 --- a/src/main/groovy/se/transmode/gradle/plugins/docker/client/NativeDockerClient.groovy +++ b/src/main/groovy/se/transmode/gradle/plugins/docker/client/NativeDockerClient.groovy @@ -43,11 +43,14 @@ class NativeDockerClient implements DockerClient { private static String executeAndWait(String cmdLine) { def process = cmdLine.execute() - process.waitFor() + // wait for process, displaying stdout and stderr + process.waitForProcessOutput(System.out,System.err) + if (process.exitValue()) { - throw new GradleException("Docker execution failed\nCommand line [${cmdLine}] returned:\n${process.err.text}") + throw new GradleException("Docker execution failed\nCommand line [${cmdLine}]") } - return process.in.text + + return "Done" } } From 1477a38910fd5bdf4f5ee5deab10446ceebf0e23 Mon Sep 17 00:00:00 2001 From: skullmaggots Date: Thu, 28 Aug 2014 16:17:17 +0100 Subject: [PATCH 2/2] Use ant copy task for adding a file into stage so that the file only gets copied if newer. This means incremental docker builds will make full use of the cache. --- .../se/transmode/gradle/plugins/docker/DockerTask.groovy | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/se/transmode/gradle/plugins/docker/DockerTask.groovy b/src/main/groovy/se/transmode/gradle/plugins/docker/DockerTask.groovy index 4731a38..e4e5cc8 100644 --- a/src/main/groovy/se/transmode/gradle/plugins/docker/DockerTask.groovy +++ b/src/main/groovy/se/transmode/gradle/plugins/docker/DockerTask.groovy @@ -18,6 +18,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.io.Files import org.gradle.api.DefaultTask +import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging import org.gradle.api.tasks.TaskAction @@ -115,10 +116,7 @@ class DockerTask extends DefaultTask { target = new File(stageDir, source.name) } stageBacklog.add { -> - project.copy { - from source - into target - } + ant.copy(file: source.absolutePath,toDir: target.absolutePath) } instructions.add("ADD ${source.name} ${destination}") }