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 import org.apache.maven.model.Model;
27 import org.apache.maven.model.Profile;
28 import org.apache.maven.model.resolution.ModelResolver;
29 import org.apache.maven.model.resolution.WorkspaceModelResolver;
30
31
32
33
34
35
36 public class DefaultModelBuildingRequest implements ModelBuildingRequest {
37 private Model fileModel;
38
39 private File pomFile;
40
41 private ModelSource modelSource;
42
43 private int validationLevel = VALIDATION_LEVEL_STRICT;
44
45 private boolean processPlugins;
46
47 private boolean twoPhaseBuilding;
48
49 private boolean locationTracking;
50
51 private List<Profile> profiles;
52
53 private List<String> activeProfileIds;
54
55 private List<String> inactiveProfileIds;
56
57 private Properties systemProperties;
58
59 private Properties userProperties;
60
61 private Date buildStartTime;
62
63 private ModelResolver modelResolver;
64
65 private ModelBuildingListener modelBuildingListener;
66
67 private ModelCache modelCache;
68
69 private WorkspaceModelResolver workspaceResolver;
70
71 private TransformerContextBuilder contextBuilder;
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 setProfiles(request.getProfiles());
90 setActiveProfileIds(request.getActiveProfileIds());
91 setInactiveProfileIds(request.getInactiveProfileIds());
92 setSystemProperties(request.getSystemProperties());
93 setUserProperties(request.getUserProperties());
94 setBuildStartTime(request.getBuildStartTime());
95 setModelResolver(request.getModelResolver());
96 setModelBuildingListener(request.getModelBuildingListener());
97 setModelCache(request.getModelCache());
98 setWorkspaceModelResolver(request.getWorkspaceModelResolver());
99 setTransformerContextBuilder(request.getTransformerContextBuilder());
100 }
101
102 @Override
103 public File getPomFile() {
104 return pomFile;
105 }
106
107 @Override
108 public DefaultModelBuildingRequest setPomFile(File pomFile) {
109 this.pomFile = (pomFile != null) ? pomFile.getAbsoluteFile() : null;
110
111 return this;
112 }
113
114 @Override
115 public synchronized ModelSource getModelSource() {
116 if (modelSource == null && pomFile != null) {
117 modelSource = new FileModelSource(pomFile);
118 }
119 return modelSource;
120 }
121
122 @Override
123 public DefaultModelBuildingRequest setModelSource(ModelSource modelSource) {
124 this.modelSource = modelSource;
125
126 return this;
127 }
128
129 @Override
130 public int getValidationLevel() {
131 return validationLevel;
132 }
133
134 @Override
135 public DefaultModelBuildingRequest setValidationLevel(int validationLevel) {
136 this.validationLevel = validationLevel;
137
138 return this;
139 }
140
141 @Override
142 public boolean isProcessPlugins() {
143 return processPlugins;
144 }
145
146 @Override
147 public DefaultModelBuildingRequest setProcessPlugins(boolean processPlugins) {
148 this.processPlugins = processPlugins;
149
150 return this;
151 }
152
153 @Override
154 public boolean isTwoPhaseBuilding() {
155 return twoPhaseBuilding;
156 }
157
158 @Override
159 public DefaultModelBuildingRequest setTwoPhaseBuilding(boolean twoPhaseBuilding) {
160 this.twoPhaseBuilding = twoPhaseBuilding;
161
162 return this;
163 }
164
165 @Override
166 public boolean isLocationTracking() {
167 return locationTracking;
168 }
169
170 @Override
171 public DefaultModelBuildingRequest setLocationTracking(boolean locationTracking) {
172 this.locationTracking = locationTracking;
173
174 return this;
175 }
176
177 @Override
178 public List<Profile> getProfiles() {
179 if (profiles == null) {
180 profiles = new ArrayList<>();
181 }
182
183 return profiles;
184 }
185
186 @Override
187 public DefaultModelBuildingRequest setProfiles(List<Profile> profiles) {
188 if (profiles != null) {
189 this.profiles = new ArrayList<>(profiles);
190 } else {
191 this.profiles = null;
192 }
193
194 return this;
195 }
196
197 @Override
198 public List<String> getActiveProfileIds() {
199 if (activeProfileIds == null) {
200 activeProfileIds = new ArrayList<>();
201 }
202
203 return activeProfileIds;
204 }
205
206 @Override
207 public DefaultModelBuildingRequest setActiveProfileIds(List<String> activeProfileIds) {
208 if (activeProfileIds != null) {
209 this.activeProfileIds = new ArrayList<>(activeProfileIds);
210 } else {
211 this.activeProfileIds = null;
212 }
213
214 return this;
215 }
216
217 @Override
218 public List<String> getInactiveProfileIds() {
219 if (inactiveProfileIds == null) {
220 inactiveProfileIds = new ArrayList<>();
221 }
222
223 return inactiveProfileIds;
224 }
225
226 @Override
227 public DefaultModelBuildingRequest setInactiveProfileIds(List<String> inactiveProfileIds) {
228 if (inactiveProfileIds != null) {
229 this.inactiveProfileIds = new ArrayList<>(inactiveProfileIds);
230 } else {
231 this.inactiveProfileIds = null;
232 }
233
234 return this;
235 }
236
237 @Override
238 public Properties getSystemProperties() {
239 if (systemProperties == null) {
240 systemProperties = new Properties();
241 }
242
243 return systemProperties;
244 }
245
246 @Override
247 public DefaultModelBuildingRequest setSystemProperties(Properties systemProperties) {
248 if (systemProperties != null) {
249 this.systemProperties = new Properties();
250 synchronized (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 getFileModel() {
332 return fileModel;
333 }
334
335 @Override
336 public ModelBuildingRequest setFileModel(Model fileModel) {
337 this.fileModel = fileModel;
338 return this;
339 }
340
341 @Override
342 public Model getRawModel() {
343 return null;
344 }
345
346 @Override
347 public ModelBuildingRequest setRawModel(Model rawModel) {
348 return this;
349 }
350
351 @Override
352 public WorkspaceModelResolver getWorkspaceModelResolver() {
353 return workspaceResolver;
354 }
355
356 @Override
357 public ModelBuildingRequest setWorkspaceModelResolver(WorkspaceModelResolver workspaceResolver) {
358 this.workspaceResolver = workspaceResolver;
359 return this;
360 }
361
362 @Override
363 public TransformerContextBuilder getTransformerContextBuilder() {
364 return contextBuilder;
365 }
366
367 @Override
368 public ModelBuildingRequest setTransformerContextBuilder(TransformerContextBuilder contextBuilder) {
369 this.contextBuilder = contextBuilder;
370 return this;
371 }
372 }