##// END OF EJS Templates
Fixed RunImage
cin -
r16:286da9ffb112 default
parent child
Show More
@@ -1,42 +1,44
1 package org.implab.gradle.containers.tasks;
1 package org.implab.gradle.containers.tasks;
2
2
3 import java.io.IOException;
3 import java.io.IOException;
4 import org.gradle.api.Action;
4 import org.gradle.api.Action;
5 import org.gradle.api.provider.ListProperty;
5 import org.gradle.api.provider.ListProperty;
6 import org.gradle.api.provider.Property;
6 import org.gradle.api.provider.Property;
7 import org.gradle.api.tasks.Input;
7 import org.gradle.api.tasks.Input;
8 import org.gradle.api.tasks.Optional;
8 import org.gradle.api.tasks.Optional;
9 import org.gradle.api.tasks.TaskAction;
9 import org.implab.gradle.containers.dsl.OptionsMixin;
10 import org.implab.gradle.containers.dsl.OptionsMixin;
10 import org.implab.gradle.containers.dsl.VolumeSpec;
11 import org.implab.gradle.containers.dsl.VolumeSpec;
11
12
12 public abstract class RunImage extends DockerCliTask implements OptionsMixin {
13 public abstract class RunImage extends DockerCliTask implements OptionsMixin {
13
14
14 @Input
15 @Input
15 public abstract Property<String> getImageName();
16 public abstract Property<String> getImageName();
16
17
17 @Input
18 @Input
18 @Optional
19 @Optional
19 public abstract ListProperty<String> getCommandLine();
20 public abstract ListProperty<String> getCommandLine();
20
21
21
22
22 public void volume(Action<VolumeSpec> configure) {
23 public void volume(Action<VolumeSpec> configure) {
23 getOptions().add("-v");
24 getOptions().add("-v");
24 getOptions().add(provider(() -> {
25 getOptions().add(provider(() -> {
25 var volumeSpec = getObjectFactory().newInstance(VolumeSpec.class);
26 var volumeSpec = getObjectFactory().newInstance(VolumeSpec.class);
26 configure.execute(volumeSpec);
27 configure.execute(volumeSpec);
27 return volumeSpec.resolveSpec();
28 return volumeSpec.resolveSpec();
28 }));
29 }));
29 }
30 }
30
31
31 void commandLine(String ...args) {
32 void commandLine(String ...args) {
32 getCommandLine().addAll(args);
33 getCommandLine().addAll(args);
33 }
34 }
34
35
36 @TaskAction
35 public void run() throws InterruptedException, IOException {
37 public void run() throws InterruptedException, IOException {
36 docker().runImage(
38 docker().runImage(
37 getImageName().get(),
39 getImageName().get(),
38 getOptions().get(),
40 getOptions().get(),
39 getCommandLine().get());
41 getCommandLine().get());
40 }
42 }
41
43
42 }
44 }
General Comments 0
You need to be logged in to leave comments. Login now