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