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