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