@@ -1,2 +1,2 | |||||
1 | group=org.implab.gradle |
|
1 | group=org.implab.gradle | |
2 |
version=1.3. |
|
2 | version=1.3.1 No newline at end of file |
@@ -2,6 +2,7 package org.implab.gradle.containers.cli | |||||
2 |
|
2 | |||
3 | import java.io.File; |
|
3 | import java.io.File; | |
4 | import java.io.IOException; |
|
4 | import java.io.IOException; | |
|
5 | import java.lang.ProcessBuilder.Redirect; | |||
5 | import java.util.ArrayList; |
|
6 | import java.util.ArrayList; | |
6 | import java.util.Collection; |
|
7 | import java.util.Collection; | |
7 | import java.util.List; |
|
8 | import java.util.List; | |
@@ -31,6 +32,15 public class ProcessSpec { | |||||
31 | builder.command(this.command); |
|
32 | builder.command(this.command); | |
32 | builder.directory(directory); |
|
33 | builder.directory(directory); | |
33 |
|
34 | |||
|
35 | // discard stdout if not redirected | |||
|
36 | if (outputRedirect == null) | |||
|
37 | builder.redirectOutput(Redirect.DISCARD); | |||
|
38 | ||||
|
39 | // discard stderr if not redirected | |||
|
40 | if (errorRedirect == null) | |||
|
41 | builder.redirectError(Redirect.DISCARD); | |||
|
42 | ||||
|
43 | // run process | |||
34 | var proc = builder.start(); |
|
44 | var proc = builder.start(); | |
35 |
|
45 | |||
36 | tasks.add(proc.onExit()); |
|
46 | tasks.add(proc.onExit()); |
@@ -19,7 +19,6 import java.nio.file.Files; | |||||
19 | import java.util.List; |
|
19 | import java.util.List; | |
20 | import org.gradle.api.Action; |
|
20 | import org.gradle.api.Action; | |
21 | import org.gradle.api.GradleException; |
|
21 | import org.gradle.api.GradleException; | |
22 | import org.gradle.api.file.Directory; |
|
|||
23 | import org.gradle.api.file.FileSystemLocation; |
|
22 | import org.gradle.api.file.FileSystemLocation; | |
24 | import org.gradle.internal.impldep.org.bouncycastle.util.Iterable; |
|
23 | import org.gradle.internal.impldep.org.bouncycastle.util.Iterable; | |
25 |
|
24 |
@@ -24,6 +24,7 import java.io.File; | |||||
24 | import java.io.IOException; |
|
24 | import java.io.IOException; | |
25 |
|
25 | |||
26 | import org.implab.gradle.containers.cli.ImageRef; |
|
26 | import org.implab.gradle.containers.cli.ImageRef; | |
|
27 | import org.implab.gradle.containers.cli.RedirectTo; | |||
27 | import org.implab.gradle.containers.cli.Utils; |
|
28 | import org.implab.gradle.containers.cli.Utils; | |
28 | import org.implab.gradle.containers.dsl.MapPropertyEntry; |
|
29 | import org.implab.gradle.containers.dsl.MapPropertyEntry; | |
29 | import org.implab.gradle.containers.dsl.OptionsMixin; |
|
30 | import org.implab.gradle.containers.dsl.OptionsMixin; | |
@@ -91,6 +92,12 public abstract class BuildImage extends | |||||
91 | } |
|
92 | } | |
92 | } |
|
93 | } | |
93 |
|
94 | |||
|
95 | @Override | |||
|
96 | protected java.util.Optional<RedirectTo> loggerErrorRedirect() { | |||
|
97 | // https://github.com/moby/buildkit/issues/1186 | |||
|
98 | return loggerInfoRedirect(); | |||
|
99 | } | |||
|
100 | ||||
94 | @TaskAction |
|
101 | @TaskAction | |
95 | public void run() throws Exception { |
|
102 | public void run() throws Exception { | |
96 | List<String> args = new ArrayList<>(); |
|
103 | List<String> args = new ArrayList<>(); |
@@ -43,11 +43,15 public abstract class DockerCliTask exte | |||||
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | protected Optional<RedirectTo> loggerInfoRedirect() { |
|
45 | protected Optional<RedirectTo> loggerInfoRedirect() { | |
46 | return getLogger().isInfoEnabled() ? Optional.of(RedirectTo.consumer(getLogger()::info)) : Optional.empty(); |
|
46 | return getLogger().isInfoEnabled() ? | |
|
47 | Optional.of(RedirectTo.consumer(getLogger()::info)) : | |||
|
48 | Optional.empty(); | |||
47 | } |
|
49 | } | |
48 |
|
50 | |||
49 | protected Optional<RedirectTo> loggerErrorRedirect() { |
|
51 | protected Optional<RedirectTo> loggerErrorRedirect() { | |
50 | return getLogger().isErrorEnabled() ? Optional.of(RedirectTo.consumer(getLogger()::error)) : Optional.empty(); |
|
52 | return getLogger().isErrorEnabled() ? | |
|
53 | Optional.of(RedirectTo.consumer(getLogger()::error)) : | |||
|
54 | Optional.empty(); | |||
51 | } |
|
55 | } | |
52 |
|
56 | |||
53 | protected Optional<RedirectTo> stdoutRedirection() { |
|
57 | protected Optional<RedirectTo> stdoutRedirection() { | |
@@ -85,7 +89,6 public abstract class DockerCliTask exte | |||||
85 | } |
|
89 | } | |
86 |
|
90 | |||
87 | protected void exec(ProcessSpec spec) throws InterruptedException, ExecutionException, IOException { |
|
91 | protected void exec(ProcessSpec spec) throws InterruptedException, ExecutionException, IOException { | |
88 |
|
||||
89 | stdoutRedirection().ifPresent(spec::redirectStdout); |
|
92 | stdoutRedirection().ifPresent(spec::redirectStdout); | |
90 | stderrRedirection().ifPresent(spec::redirectStderr); |
|
93 | stderrRedirection().ifPresent(spec::redirectStderr); | |
91 | stdinRedirection().ifPresent(spec::redirectStdin); |
|
94 | stdinRedirection().ifPresent(spec::redirectStdin); |
General Comments 0
You need to be logged in to leave comments.
Login now