1
2
3
4
5 package org.apache.maven.plugin.lifecycle;
6
7 import java.io.Serializable;
8 import java.util.ArrayList;
9 import java.util.Collection;
10 import java.util.Collections;
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14 import org.apache.maven.api.annotations.Experimental;
15 import org.apache.maven.api.annotations.Generated;
16 import org.apache.maven.api.annotations.Immutable;
17 import org.apache.maven.api.annotations.Nonnull;
18 import org.apache.maven.api.annotations.NotThreadSafe;
19 import org.apache.maven.api.annotations.ThreadSafe;
20 import org.apache.maven.api.xml.XmlNode;
21
22
23
24
25 @Experimental
26 @Generated @ThreadSafe @Immutable
27 public class Execution
28 implements Serializable
29 {
30
31
32
33 final XmlNode configuration;
34
35
36
37 final List<String> goals;
38
39
40
41
42
43 Execution(
44 XmlNode configuration,
45 Collection<String> goals
46 ) {
47 this.configuration = configuration;
48 this.goals = ImmutableCollections.copy(goals);
49 }
50
51
52
53
54
55
56 public XmlNode getConfiguration() {
57 return this.configuration;
58 }
59
60
61
62
63
64
65 @Nonnull
66 public List<String> getGoals() {
67 return this.goals;
68 }
69
70
71
72
73
74
75 @Nonnull
76 public Builder with() {
77 return newBuilder(this);
78 }
79
80
81
82
83
84
85 @Nonnull
86 public Execution withConfiguration(XmlNode configuration) {
87 return newBuilder(this, true).configuration(configuration).build();
88 }
89
90
91
92
93
94
95 @Nonnull
96 public Execution withGoals(Collection<String> goals) {
97 return newBuilder(this, true).goals(goals).build();
98 }
99
100
101
102
103
104
105
106
107 @Nonnull
108 public static Execution newInstance() {
109 return newInstance(true);
110 }
111
112
113
114
115
116
117
118
119 @Nonnull
120 public static Execution newInstance(boolean withDefaults) {
121 return newBuilder(withDefaults).build();
122 }
123
124
125
126
127
128
129
130
131 @Nonnull
132 public static Builder newBuilder() {
133 return newBuilder(true);
134 }
135
136
137
138
139
140
141
142 @Nonnull
143 public static Builder newBuilder(boolean withDefaults) {
144 return new Builder(withDefaults);
145 }
146
147
148
149
150
151
152
153
154 @Nonnull
155 public static Builder newBuilder(Execution from) {
156 return newBuilder(from, false);
157 }
158
159
160
161
162
163
164
165
166 @Nonnull
167 public static Builder newBuilder(Execution from, boolean forceCopy) {
168 return new Builder(from, forceCopy);
169 }
170
171
172
173
174
175
176 @NotThreadSafe
177 public static class Builder
178 {
179 Execution base;
180 XmlNode configuration;
181 Collection<String> goals;
182
183 Builder(boolean withDefaults) {
184 if (withDefaults) {
185 }
186 }
187
188 Builder(Execution base, boolean forceCopy) {
189 if (forceCopy) {
190 this.configuration = base.configuration;
191 this.goals = base.goals;
192 } else {
193 this.base = base;
194 }
195 }
196
197 @Nonnull
198 public Builder configuration(XmlNode configuration) {
199 this.configuration = configuration;
200 return this;
201 }
202
203 @Nonnull
204 public Builder goals(Collection<String> goals) {
205 this.goals = goals;
206 return this;
207 }
208
209
210 @Nonnull
211 public Execution build() {
212 if (base != null
213 && (configuration == null || configuration == base.configuration)
214 && (goals == null || goals == base.goals)
215 ) {
216 return base;
217 }
218 return new Execution(
219 configuration != null ? configuration : (base != null ? base.configuration : null),
220 goals != null ? goals : (base != null ? base.goals : null)
221 );
222 }
223 }
224
225 }