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 {
48 this.configuration = configuration;
49 this.goals = ImmutableCollections.copy( goals );
50 }
51
52
53
54
55
56
57 public XmlNode getConfiguration()
58 {
59 return this.configuration;
60 }
61
62
63
64
65
66
67 @Nonnull
68 public List<String> getGoals()
69 {
70 return this.goals;
71 }
72
73
74
75
76
77
78 @Nonnull
79 public Builder with()
80 {
81 return newBuilder( this );
82 }
83
84
85
86
87
88
89 @Nonnull
90 public Execution withConfiguration( XmlNode configuration )
91 {
92 return with().configuration( configuration ).build();
93 }
94
95
96
97
98
99
100 @Nonnull
101 public Execution withGoals( Collection<String> goals )
102 {
103 return with().goals( goals ).build();
104 }
105
106
107
108
109
110
111
112
113 @Nonnull
114 public static Execution newInstance()
115 {
116 return newInstance( true );
117 }
118
119
120
121
122
123
124
125
126 @Nonnull
127 public static Execution newInstance( boolean withDefaults )
128 {
129 return newBuilder( withDefaults ).build();
130 }
131
132
133
134
135
136
137
138
139 @Nonnull
140 public static Builder newBuilder()
141 {
142 return newBuilder( true );
143 }
144
145
146
147
148
149
150
151 @Nonnull
152 public static Builder newBuilder( boolean withDefaults )
153 {
154 return new Builder( withDefaults );
155 }
156
157
158
159
160
161
162
163
164 @Nonnull
165 public static Builder newBuilder( Execution from )
166 {
167 return newBuilder( from, false );
168 }
169
170
171
172
173
174
175
176
177 @Nonnull
178 public static Builder newBuilder( Execution from, boolean forceCopy )
179 {
180 return new Builder( from, forceCopy );
181 }
182
183
184
185
186
187
188 @NotThreadSafe
189 public static class Builder
190 {
191 Execution base;
192 XmlNode configuration;
193 Collection<String> goals;
194
195 Builder( boolean withDefaults )
196 {
197 if ( withDefaults )
198 {
199 }
200 }
201
202 Builder( Execution base, boolean forceCopy )
203 {
204 if ( forceCopy )
205 {
206 this.configuration = base.configuration;
207 this.goals = base.goals;
208 }
209 else
210 {
211 this.base = base;
212 }
213 }
214
215 @Nonnull
216 public Builder configuration( XmlNode configuration )
217 {
218 this.configuration = configuration;
219 return this;
220 }
221
222 @Nonnull
223 public Builder goals( Collection<String> goals )
224 {
225 this.goals = goals;
226 return this;
227 }
228
229
230 @Nonnull
231 public Execution build()
232 {
233 if ( base != null
234 && ( configuration == null || configuration == base.configuration )
235 && ( goals == null || goals == base.goals )
236 )
237 {
238 return base;
239 }
240 return new Execution(
241 configuration != null ? configuration : ( base != null ? base.configuration : null ),
242 goals != null ? goals : ( base != null ? base.goals : null )
243 );
244 }
245 }
246
247 }