1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven.model.building;
20
21 import java.io.File;
22 import java.nio.file.Path;
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 * Collects settings that control the building of effective models.
34 *
35 * @deprecated use {@link org.apache.maven.api.services.ModelBuilder} instead
36 */
37 @Deprecated(since = "4.0.0")
38 public interface ModelBuildingRequest {
39
40 /**
41 * Denotes minimal validation of POMs. This validation level is meant for processing of POMs from repositories
42 * during metadata retrieval.
43 */
44 int VALIDATION_LEVEL_MINIMAL = 0;
45
46 /**
47 * Denotes validation as performed by Maven 2.0. This validation level is meant as a compatibility mode to allow
48 * users to migrate their projects.
49 */
50 int VALIDATION_LEVEL_MAVEN_2_0 = 20;
51
52 /**
53 * Denotes validation as performed by Maven 3.0. This validation level is meant for existing projects.
54 */
55 int VALIDATION_LEVEL_MAVEN_3_0 = 30;
56
57 /**
58 * Denotes validation as performed by Maven 3.1. This validation level is meant for existing projects.
59 */
60 int VALIDATION_LEVEL_MAVEN_3_1 = 31;
61
62 /**
63 * Denotes validation as performed by Maven 4.0. This validation level is meant for new projects.
64 */
65 int VALIDATION_LEVEL_MAVEN_4_0 = 40;
66
67 /**
68 * Denotes strict validation as recommended by the current Maven version.
69 */
70 int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_4_0;
71
72 /**
73 * Gets the file model to build (with profile activation).
74 * If not set, model source will be used to load file model.
75 *
76 * @return The file model to build or {@code null} if not set.
77 * @since 4.0.0
78 */
79 Model getFileModel();
80
81 /**
82 * Set the file model with profile activation
83 *
84 * @param fileModel
85 * @return This request, never {@code null}.
86 * @since 4.0.0
87 */
88 ModelBuildingRequest setFileModel(Model fileModel);
89
90 /**
91 * @deprecated rawModel is never set, instead the fileModel is set
92 */
93 @Deprecated
94 Model getRawModel();
95
96 /**
97 * @deprecated setting the rawModel has no effect, instead the fileModel of phase one will be set
98 */
99 @Deprecated
100 ModelBuildingRequest setRawModel(Model rawModel);
101
102 /**
103 * Gets the source of the POM to process.
104 *
105 * @return The source of the POM or {@code null} if not set.
106 */
107 ModelSource getModelSource();
108
109 /**
110 * Sets the source of the POM to process. Eventually, either {@link #setModelSource(ModelSource)} or
111 * {@link #setPomPath(Path)} must be set.
112 *
113 * @param modelSource The source of the POM to process, may be {@code null}.
114 * @return This request, never {@code null}.
115 */
116 ModelBuildingRequest setModelSource(ModelSource modelSource);
117
118 /**
119 * Gets the POM file of the project to build.
120 *
121 * @return The POM file of the project or {@code null} if not applicable (i.e. when processing a POM from the
122 * repository).
123 * @deprecated Use {@link #getPomPath()} instead.
124 */
125 @Deprecated
126 File getPomFile();
127
128 /**
129 * Gets the POM file of the project to build.
130 *
131 * @return The POM file of the project or {@code null} if not applicable (i.e. when processing a POM from the
132 * repository).
133 * @since 4.0.0
134 */
135 Path getPomPath();
136
137 /**
138 * Sets the POM file of the project to build. Note that providing the path to a POM file via this method will make
139 * the model builder operate in project mode. This mode is meant for effective models that are employed during the
140 * build process of a local project. Hence the effective model will support the notion of a project directory. To
141 * build the model for a POM from the repository, use {@link #setModelSource(ModelSource)} in combination with a
142 * {@link FileModelSource} instead.
143 *
144 * @param pomFile The POM file of the project to build the effective model for, may be {@code null} to build the
145 * model of some POM from the repository.
146 * @return This request, never {@code null}.
147 * @deprecated Use {@link #setPomPath(Path)} instead.
148 */
149 @Deprecated
150 ModelBuildingRequest setPomFile(File pomFile);
151
152 /**
153 * Sets the POM file of the project to build. Note that providing the path to a POM file via this method will make
154 * the model builder operate in project mode. This mode is meant for effective models that are employed during the
155 * build process of a local project. Hence the effective model will support the notion of a project directory. To
156 * build the model for a POM from the repository, use {@link #setModelSource(ModelSource)} in combination with a
157 * {@link FileModelSource} instead.
158 *
159 * @param pomPath The POM file of the project to build the effective model for, may be {@code null} to build the
160 * model of some POM from the repository.
161 * @return This request, never {@code null}.
162 * @since 4.0.0
163 */
164 ModelBuildingRequest setPomPath(Path pomPath);
165
166 /**
167 * Gets the level of validation to perform on processed models.
168 *
169 * @return The level of validation to perform on processed models.
170 */
171 int getValidationLevel();
172
173 /**
174 * Sets the level of validation to perform on processed models. For building of projects,
175 * {@link #VALIDATION_LEVEL_STRICT} should be used to ensure proper building. For the mere retrieval of dependencies
176 * during artifact resolution, {@link #VALIDATION_LEVEL_MINIMAL} should be used to account for models of poor
177 * quality. By default, models are validated in strict mode.
178 *
179 * @param validationLevel The level of validation to perform on processed models.
180 * @return This request, never {@code null}.
181 */
182 ModelBuildingRequest setValidationLevel(int validationLevel);
183
184 /**
185 * Indicates whether plugin executions and configurations should be processed. If enabled, lifecycle-induced plugin
186 * executions will be injected into the model and common plugin configuration will be propagated to individual
187 * executions.
188 *
189 * @return {@code true} if plugins should be processed, {@code false} otherwise.
190 */
191 boolean isProcessPlugins();
192
193 /**
194 * Controls the processing of plugin executions and configurations.
195 *
196 * @param processPlugins {@code true} to enable plugin processing, {@code false} otherwise.
197 * @return This request, never {@code null}.
198 */
199 ModelBuildingRequest setProcessPlugins(boolean processPlugins);
200
201 /**
202 * Indicates whether the model building should happen in two phases. If enabled, the initial invocation of the model
203 * builder will only produce an interim result which may be used to analyze inter-model dependencies before the
204 * final invocation of the model builder is performed.
205 *
206 * @return {@code true} if two-phase building is enabled, {@code false} if the model should be build in a single
207 * step.
208 */
209 boolean isTwoPhaseBuilding();
210
211 /**
212 * Enables/disables two-phase building. If enabled, the initial invocation of the model builder will only produce an
213 * interim result which may be used to analyze inter-model dependencies before the final invocation of the model
214 * builder is performed.
215 *
216 * @param twoPhaseBuilding {@code true} to enable two-phase building, {@code false} if the model should be build in
217 * a single step.
218 * @return This request, never {@code null}.
219 */
220 ModelBuildingRequest setTwoPhaseBuilding(boolean twoPhaseBuilding);
221
222 /**
223 * Indicates whether the model should track the line/column number of the model source from which it was parsed.
224 *
225 * @return {@code true} if location tracking is enabled, {@code false} otherwise.
226 */
227 boolean isLocationTracking();
228
229 /**
230 * Enables/disables the tracking of line/column numbers for the model source being parsed. By default, input
231 * locations are not tracked.
232 *
233 * @param locationTracking {@code true} to enable location tracking, {@code false} to disable it.
234 * @return This request, never {@code null}.
235 */
236 ModelBuildingRequest setLocationTracking(boolean locationTracking);
237
238 /**
239 * Gets the external profiles that should be considered for model building.
240 *
241 * @return The external profiles that should be considered for model building, never {@code null}.
242 */
243 List<Profile> getProfiles();
244
245 /**
246 * Sets the external profiles that should be considered for model building.
247 *
248 * @param profiles The external profiles that should be considered for model building, may be {@code null}.
249 * @return This request, never {@code null}.
250 */
251 ModelBuildingRequest setProfiles(List<Profile> profiles);
252
253 /**
254 * Gets the identifiers of those profiles that should be activated by explicit demand.
255 *
256 * @return The identifiers of those profiles to activate, never {@code null}.
257 */
258 List<String> getActiveProfileIds();
259
260 /**
261 * Sets the identifiers of those profiles that should be activated by explicit demand.
262 *
263 * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}.
264 * @return This request, never {@code null}.
265 */
266 ModelBuildingRequest setActiveProfileIds(List<String> activeProfileIds);
267
268 /**
269 * Gets the identifiers of those profiles that should be deactivated by explicit demand.
270 *
271 * @return The identifiers of those profiles to deactivate, never {@code null}.
272 */
273 List<String> getInactiveProfileIds();
274
275 /**
276 * Sets the identifiers of those profiles that should be deactivated by explicit demand.
277 *
278 * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}.
279 * @return This request, never {@code null}.
280 */
281 ModelBuildingRequest setInactiveProfileIds(List<String> inactiveProfileIds);
282
283 /**
284 * Gets the system properties to use for interpolation and profile activation. The system properties are collected
285 * from the runtime environment like {@link System#getProperties()} and environment variables.
286 *
287 * @return The system properties, never {@code null}.
288 */
289 Properties getSystemProperties();
290
291 /**
292 * Sets the system properties to use for interpolation and profile activation. The system properties are collected
293 * from the runtime environment like {@link System#getProperties()} and environment variables.
294 *
295 * @param systemProperties The system properties, may be {@code null}.
296 * @return This request, never {@code null}.
297 */
298 ModelBuildingRequest setSystemProperties(Properties systemProperties);
299
300 /**
301 * Gets the user properties to use for interpolation and profile activation. The user properties have been
302 * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command
303 * line.
304 *
305 * @return The user properties, never {@code null}.
306 */
307 Properties getUserProperties();
308
309 /**
310 * Sets the user properties to use for interpolation and profile activation. The user properties have been
311 * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command
312 * line.
313 *
314 * @param userProperties The user properties, may be {@code null}.
315 * @return This request, never {@code null}.
316 */
317 ModelBuildingRequest setUserProperties(Properties userProperties);
318
319 /**
320 * Gets the start time of the build.
321 *
322 * @return The start time of the build or {@code null} if unknown.
323 */
324 Date getBuildStartTime();
325
326 /**
327 * Sets the start time of the build.
328 *
329 * @param buildStartTime The start time of the build, may be {@code null}.
330 * @return This request, never {@code null}.
331 */
332 ModelBuildingRequest setBuildStartTime(Date buildStartTime);
333
334 /**
335 * Gets the model resolver to use for resolution of mixins or parents that are not locally reachable from the
336 * project directory.
337 *
338 * @return The model resolver or {@code null} if not set.
339 */
340 ModelResolver getModelResolver();
341
342 /**
343 * Sets the model resolver to use for resolution of mixins or parents that are not locally reachable from the
344 * project directory.
345 *
346 * @param modelResolver The model resolver to use, never {@code null}.
347 * @return This request, never {@code null}.
348 */
349 ModelBuildingRequest setModelResolver(ModelResolver modelResolver);
350
351 /**
352 * Gets the model building listener to notify during the build process.
353 *
354 * @return The model building listener to notify or {@code null} if none.
355 */
356 ModelBuildingListener getModelBuildingListener();
357
358 /**
359 * Sets the model building listener to notify during the build process.
360 *
361 * @param modelBuildingListener The model building listener to notify, may be {@code null}.
362 * @return This request, never {@code null}.
363 */
364 ModelBuildingRequest setModelBuildingListener(ModelBuildingListener modelBuildingListener);
365
366 /**
367 * Gets the model cache to use for reuse of previously built models.
368 *
369 * @return The model cache or {@code null} if not set.
370 */
371 ModelCache getModelCache();
372
373 /**
374 * Sets the model cache to use for reuse of previously built models. This is an optional component that serves
375 * performance optimizations.
376 *
377 * @param modelCache The model cache to use, may be {@code null}.
378 * @return This request, never {@code null}.
379 */
380 ModelBuildingRequest setModelCache(ModelCache modelCache);
381
382 WorkspaceModelResolver getWorkspaceModelResolver();
383
384 ModelBuildingRequest setWorkspaceModelResolver(WorkspaceModelResolver workspaceResolver);
385
386 TransformerContextBuilder getTransformerContextBuilder();
387
388 ModelBuildingRequest setTransformerContextBuilder(TransformerContextBuilder contextBuilder);
389
390 Path getRootDirectory();
391
392 ModelBuildingRequest setRootDirectory(Path rootDirectory);
393 }