1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.nicoulaj.maven.plugins.vagrant;
17
18 import de.saumya.mojo.ruby.script.ScriptException;
19 import org.apache.maven.plugins.annotations.Mojo;
20 import org.apache.maven.plugins.annotations.Parameter;
21
22 import java.io.IOException;
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import static org.codehaus.plexus.util.StringUtils.isEmpty;
27 import static org.codehaus.plexus.util.StringUtils.join;
28
29
30
31
32
33
34
35 @SuppressWarnings("unused")
36 @Mojo(name = "up")
37 public final class UpMojo extends AbstractVagrantMojo {
38
39
40 public static final String NAME = "up";
41
42
43
44
45 @Parameter
46 protected String vm;
47
48
49
50
51 @Parameter(defaultValue = "true")
52 protected boolean provision;
53
54
55
56
57 @Parameter
58 protected List<String> provisioners;
59
60 @Override
61 protected void doExecute() throws IOException, ScriptException {
62
63 final List<String> args = new ArrayList<String>();
64
65 args.add(NAME);
66
67 if (!isEmpty(vm))
68 args.add(vm);
69
70 if (!provision)
71 args.add("--no-provision");
72
73 else if (provisioners != null && !provisioners.isEmpty()) {
74 args.add("--provision");
75 args.add("--provision-with");
76 args.add(join(provisioners.iterator(), ","));
77
78 } else
79 args.add("--provision");
80
81 cli(args);
82 }
83 }