| @@ -3,7 +3,7 package org.implab.gradle.common.dsl; | |||
|
|
3 | 3 | |
|
|
4 | 4 | import org.gradle.api.provider.ListProperty; |
|
|
5 | 5 | |
|
|
6 | public interface CommandSpec { | |
|
|
6 | public interface TaskCommandSpecMixin { | |
|
|
7 | 7 | ListProperty<String> getCommandLine(); |
|
|
8 | 8 | |
|
|
9 | 9 | void commandLine(Object arg0, Object... args); |
| @@ -6,6 +6,7 import java.util.Map; | |||
|
|
6 | 6 | import org.gradle.api.Action; |
|
|
7 | 7 | import org.gradle.api.file.DirectoryProperty; |
|
|
8 | 8 | import org.gradle.api.provider.MapProperty; |
|
|
9 | import org.gradle.api.provider.Property; | |
|
|
9 | 10 | import org.implab.gradle.common.utils.Closures; |
|
|
10 | 11 | import org.implab.gradle.common.utils.Values; |
|
|
11 | 12 | |
| @@ -16,7 +17,10 import groovy.lang.Closure; | |||
|
|
16 | 17 | * working directory and environment variables for the processes started within |
|
|
17 | 18 | * this shell. |
|
|
18 | 19 | */ |
|
|
19 |
public interface Env |
|
|
|
20 | public interface TaskEnvSpecMixin { | |
|
|
21 | ||
|
|
22 | /** Inherit environment from current process */ | |
|
|
23 | Property<Boolean> getInheritEnvironment(); | |
|
|
20 | 24 | |
|
|
21 | 25 | /** Working directory */ |
|
|
22 | 26 | DirectoryProperty getWorkingDirectory(); |
| @@ -3,7 +3,7 package org.implab.gradle.common.dsl; | |||
|
|
3 | 3 | import org.eclipse.jdt.annotation.NonNullByDefault; |
|
|
4 | 4 | |
|
|
5 | 5 | @NonNullByDefault |
|
|
6 | public interface PipeSpec { | |
|
|
6 | public interface TaskPipeSpecMixin { | |
|
|
7 | 7 | RedirectToSpec getStdout(); |
|
|
8 | 8 | |
|
|
9 | 9 | RedirectToSpec getStderr(); |
| @@ -9,13 +9,14 import org.gradle.api.DefaultTask; | |||
|
|
9 | 9 | import org.gradle.api.file.DirectoryProperty; |
|
|
10 | 10 | import org.gradle.api.provider.ListProperty; |
|
|
11 | 11 | import org.gradle.api.provider.MapProperty; |
|
|
12 | import org.gradle.api.provider.Property; | |
|
|
12 | 13 | import org.gradle.api.tasks.Internal; |
|
|
13 | 14 | import org.gradle.api.tasks.TaskAction; |
|
|
14 | import org.implab.gradle.common.dsl.CommandSpec; | |
|
|
15 | import org.implab.gradle.common.dsl.PipeSpec; | |
|
|
15 | import org.implab.gradle.common.dsl.TaskCommandSpecMixin; | |
|
|
16 | import org.implab.gradle.common.dsl.TaskPipeSpecMixin; | |
|
|
16 | 17 | import org.implab.gradle.common.dsl.RedirectFromSpec; |
|
|
17 | 18 | import org.implab.gradle.common.dsl.RedirectToSpec; |
|
|
18 |
import org.implab.gradle.common.dsl.Env |
|
|
|
19 | import org.implab.gradle.common.dsl.TaskEnvSpecMixin; | |
|
|
19 | 20 | import org.implab.gradle.common.exec.ExecBuilder; |
|
|
20 | 21 | import org.implab.gradle.common.utils.ObjectsMixin; |
|
|
21 | 22 | import org.implab.gradle.common.utils.Strings; |
| @@ -23,7 +24,7 import org.implab.gradle.common.utils.Th | |||
|
|
23 | 24 | |
|
|
24 | 25 | public abstract class ShellExecTask |
|
|
25 | 26 | extends DefaultTask |
|
|
26 |
implements CommandSpec, PipeSpec, Env |
|
|
|
27 | implements TaskCommandSpecMixin, TaskPipeSpecMixin, TaskEnvSpecMixin, ObjectsMixin { | |
|
|
27 | 28 | |
|
|
28 | 29 | private final RedirectToSpec redirectStderr = new RedirectToSpec(); |
|
|
29 | 30 | |
| @@ -33,6 +34,10 public abstract class ShellExecTask | |||
|
|
33 | 34 | |
|
|
34 | 35 | @Internal |
|
|
35 | 36 | @Override |
|
|
37 | public abstract Property<Boolean> getInheritEnvironment(); | |
|
|
38 | ||
|
|
39 | @Internal | |
|
|
40 | @Override | |
|
|
36 | 41 | public abstract DirectoryProperty getWorkingDirectory(); |
|
|
37 | 42 | |
|
|
38 | 43 | @Internal |
| @@ -11,10 +11,7 public final class Closures { | |||
|
|
11 | 11 | } |
|
|
12 | 12 | |
|
|
13 | 13 | public static <T> Action<T> action(Closure<?> closure) { |
|
|
14 |
return arg -> |
|
|
|
15 | closure.setDelegate(arg); | |
|
|
16 | closure.call(arg); | |
|
|
17 | }; | |
|
|
14 | return arg -> apply(closure, arg); | |
|
|
18 | 15 | } |
|
|
19 | 16 | |
|
|
20 | 17 | public static void apply(Closure<?> action, Object target) { |
| @@ -66,6 +66,10 public final class Values { | |||
|
|
66 | 66 | return () -> new ArrayIterator<>(values); |
|
|
67 | 67 | } |
|
|
68 | 68 | |
|
|
69 | public static <T> Optional<T> optional(Provider<T> provider) { | |
|
|
70 | return provider.isPresent() ? Optional.of(provider.get()) : Optional.empty(); | |
|
|
71 | } | |
|
|
72 | ||
|
|
69 | 73 | private static class ArrayIterator<T> implements Iterator<T> { |
|
|
70 | 74 | private final T[] data; |
|
|
71 | 75 | |
|
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now
