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