1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.model.building;
20
21 import java.io.File;
22 import java.util.ArrayList;
23 import java.util.Date;
24 import java.util.List;
25 import java.util.Properties;
26
27 import org.apache.maven.model.Model;
28 import org.apache.maven.model.Profile;
29 import org.apache.maven.model.resolution.ModelResolver;
30 import org.apache.maven.model.resolution.WorkspaceModelResolver;
31
32
33
34
35
36
37 public class DefaultModelBuildingRequest implements ModelBuildingRequest {
38
39 private Model rawModel;
40
41 private File pomFile;
42
43 private ModelSource modelSource;
44
45 private int validationLevel = VALIDATION_LEVEL_STRICT;
46
47 private boolean processPlugins;
48
49 private boolean twoPhaseBuilding;
50
51 private boolean locationTracking;
52
53 private List<Profile> profiles;
54
55 private List<String> activeProfileIds;
56
57 private List<String> inactiveProfileIds;
58
59 private Properties systemProperties;
60
61 private Properties userProperties;
62
63 private Date buildStartTime;
64
65 private ModelResolver modelResolver;
66
67 private ModelBuildingListener modelBuildingListener;
68
69 private ModelCache modelCache;
70
71 private WorkspaceModelResolver workspaceResolver;
72
73
74
75
76 public DefaultModelBuildingRequest() {}
77
78
79
80
81
82
83 public DefaultModelBuildingRequest(ModelBuildingRequest request) {
84 setPomFile(request.getPomFile());
85 setModelSource(request.getModelSource());
86 setValidationLevel(request.getValidationLevel());
87 setProcessPlugins(request.isProcessPlugins());
88 setTwoPhaseBuilding(request.isTwoPhaseBuilding());
89 setLocationTracking(request.isLocationTracking());
90 setProfiles(request.getProfiles());
91 setActiveProfileIds(request.getActiveProfileIds());
92 setInactiveProfileIds(request.getInactiveProfileIds());
93 setSystemProperties(request.getSystemProperties());
94 setUserProperties(request.getUserProperties());
95 setBuildStartTime(request.getBuildStartTime());
96 setModelResolver(request.getModelResolver());
97 setModelBuildingListener(request.getModelBuildingListener());
98 setModelCache(request.getModelCache());
99 }
100
101 @Override
102 public File getPomFile() {
103 return pomFile;
104 }
105
106 @Override
107 public DefaultModelBuildingRequest setPomFile(File pomFile) {
108 this.pomFile = (pomFile != null) ? pomFile.getAbsoluteFile() : null;
109
110 return this;
111 }
112
113 @Override
114 public synchronized ModelSource getModelSource() {
115 if (modelSource == null && pomFile != null) {
116 modelSource = new FileModelSource(pomFile);
117 }
118 return modelSource;
119 }
120
121 @Override
122 public DefaultModelBuildingRequest setModelSource(ModelSource modelSource) {
123 this.modelSource = modelSource;
124
125 return this;
126 }
127
128 @Override
129 public int getValidationLevel() {
130 return validationLevel;
131 }
132
133 @Override
134 public DefaultModelBuildingRequest setValidationLevel(int validationLevel) {
135 this.validationLevel = validationLevel;
136
137 return this;
138 }
139
140 @Override
141 public boolean isProcessPlugins() {
142 return processPlugins;
143 }
144
145 @Override
146 public DefaultModelBuildingRequest setProcessPlugins(boolean processPlugins) {
147 this.processPlugins = processPlugins;
148
149 return this;
150 }
151
152 @Override
153 public boolean isTwoPhaseBuilding() {
154 return twoPhaseBuilding;
155 }
156
157 @Override
158 public DefaultModelBuildingRequest setTwoPhaseBuilding(boolean twoPhaseBuilding) {
159 this.twoPhaseBuilding = twoPhaseBuilding;
160
161 return this;
162 }
163
164 @Override
165 public boolean isLocationTracking() {
166 return locationTracking;
167 }
168
169 @Override
170 public DefaultModelBuildingRequest setLocationTracking(boolean locationTracking) {
171 this.locationTracking = locationTracking;
172
173 return this;
174 }
175
176 @Override
177 public List<Profile> getProfiles() {
178 if (profiles == null) {
179 profiles = new ArrayList<>();
180 }
181
182 return profiles;
183 }
184
185 @Override
186 public DefaultModelBuildingRequest setProfiles(List<Profile> profiles) {
187 if (profiles != null) {
188 this.profiles = new ArrayList<>(profiles);
189 } else {
190 this.profiles = null;
191 }
192
193 return this;
194 }
195
196 @Override
197 public List<String> getActiveProfileIds() {
198 if (activeProfileIds == null) {
199 activeProfileIds = new ArrayList<>();
200 }
201
202 return activeProfileIds;
203 }
204
205 @Override
206 public DefaultModelBuildingRequest setActiveProfileIds(List<String> activeProfileIds) {
207 if (activeProfileIds != null) {
208 this.activeProfileIds = new ArrayList<>(activeProfileIds);
209 } else {
210 this.activeProfileIds = null;
211 }
212
213 return this;
214 }
215
216 @Override
217 public List<String> getInactiveProfileIds() {
218 if (inactiveProfileIds == null) {
219 inactiveProfileIds = new ArrayList<>();
220 }
221
222 return inactiveProfileIds;
223 }
224
225 @Override
226 public DefaultModelBuildingRequest setInactiveProfileIds(List<String> inactiveProfileIds) {
227 if (inactiveProfileIds != null) {
228 this.inactiveProfileIds = new ArrayList<>(inactiveProfileIds);
229 } else {
230 this.inactiveProfileIds = null;
231 }
232
233 return this;
234 }
235
236 @Override
237 public Properties getSystemProperties() {
238 if (systemProperties == null) {
239 systemProperties = new Properties();
240 }
241
242 return systemProperties;
243 }
244
245 @Override
246 public DefaultModelBuildingRequest setSystemProperties(Properties systemProperties) {
247 if (systemProperties != null) {
248 this.systemProperties = new Properties();
249 synchronized (
250 systemProperties) {
251
252 this.systemProperties.putAll(systemProperties);
253 }
254 } else {
255 this.systemProperties = null;
256 }
257
258 return this;
259 }
260
261 @Override
262 public Properties getUserProperties() {
263 if (userProperties == null) {
264 userProperties = new Properties();
265 }
266
267 return userProperties;
268 }
269
270 @Override
271 public DefaultModelBuildingRequest setUserProperties(Properties userProperties) {
272 if (userProperties != null) {
273 this.userProperties = new Properties();
274 this.userProperties.putAll(userProperties);
275 } else {
276 this.userProperties = null;
277 }
278
279 return this;
280 }
281
282 @Override
283 public Date getBuildStartTime() {
284 return buildStartTime;
285 }
286
287 @Override
288 public ModelBuildingRequest setBuildStartTime(Date buildStartTime) {
289 this.buildStartTime = buildStartTime;
290
291 return this;
292 }
293
294 @Override
295 public ModelResolver getModelResolver() {
296 return this.modelResolver;
297 }
298
299 @Override
300 public DefaultModelBuildingRequest setModelResolver(ModelResolver modelResolver) {
301 this.modelResolver = modelResolver;
302
303 return this;
304 }
305
306 @Override
307 public ModelBuildingListener getModelBuildingListener() {
308 return modelBuildingListener;
309 }
310
311 @Override
312 public ModelBuildingRequest setModelBuildingListener(ModelBuildingListener modelBuildingListener) {
313 this.modelBuildingListener = modelBuildingListener;
314
315 return this;
316 }
317
318 @Override
319 public ModelCache getModelCache() {
320 return this.modelCache;
321 }
322
323 @Override
324 public DefaultModelBuildingRequest setModelCache(ModelCache modelCache) {
325 this.modelCache = modelCache;
326
327 return this;
328 }
329
330 @Override
331 public Model getRawModel() {
332 return rawModel;
333 }
334
335 @Override
336 public ModelBuildingRequest setRawModel(Model rawModel) {
337 this.rawModel = rawModel;
338 return this;
339 }
340
341 @Override
342 public WorkspaceModelResolver getWorkspaceModelResolver() {
343 return workspaceResolver;
344 }
345
346 @Override
347 public ModelBuildingRequest setWorkspaceModelResolver(WorkspaceModelResolver workspaceResolver) {
348 this.workspaceResolver = workspaceResolver;
349 return this;
350 }
351 }