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.util.Date;
23 import java.util.List;
24 import java.util.Properties;
25
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 * Collects settings that control the building of effective models.
33 *
34 * @deprecated use {@code org.apache.maven.api.services.ModelBuilder} instead
35 */
36 @Deprecated(since = "4.0.0")
37 public interface ModelBuildingRequest {
38
39 /**
40 * Denotes minimal validation of POMs. This validation level is meant for processing of POMs from repositories
41 * during metadata retrieval.
42 */
43 int VALIDATION_LEVEL_MINIMAL = 0;
44
45 /**
46 * Denotes validation as performed by Maven 2.0. This validation level is meant as a compatibility mode to allow
47 * users to migrate their projects.
48 */
49 int VALIDATION_LEVEL_MAVEN_2_0 = 20;
50
51 /**
52 * Denotes validation as performed by Maven 3.0. This validation level is meant for existing projects.
53 */
54 int VALIDATION_LEVEL_MAVEN_3_0 = 30;
55
56 /**
57 * Denotes validation as performed by Maven 3.1. This validation level is meant for new projects.
58 */
59 int VALIDATION_LEVEL_MAVEN_3_1 = 31;
60
61 /**
62 * Denotes strict validation as recommended by the current Maven version.
63 */
64 int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_0;
65
66 /**
67 * Gets the raw model to build. If not set, model source will be used to load raw model.
68 *
69 * @return The raw model to build or {@code null} if not set.
70 */
71 Model getRawModel();
72
73 /**
74 * Set raw model.
75 *
76 * @param rawModel
77 */
78 ModelBuildingRequest setRawModel(Model rawModel);
79
80 /**
81 * Gets the source of the POM to process.
82 *
83 * @return The source of the POM or {@code null} if not set.
84 */
85 ModelSource getModelSource();
86
87 /**
88 * Sets the source of the POM to process. Eventually, either {@link #setModelSource(ModelSource)} or
89 * {@link #setPomFile(File)} must be set.
90 *
91 * @param modelSource The source of the POM to process, may be {@code null}.
92 * @return This request, never {@code null}.
93 */
94 ModelBuildingRequest setModelSource(ModelSource modelSource);
95
96 /**
97 * Gets the POM file of the project to build.
98 *
99 * @return The POM file of the project or {@code null} if not applicable (i.e. when processing a POM from the
100 * repository).
101 */
102 File getPomFile();
103
104 /**
105 * Sets the POM file of the project to build. Note that providing the path to a POM file via this method will make
106 * the model builder operate in project mode. This mode is meant for effective models that are employed during the
107 * build process of a local project. Hence the effective model will support the notion of a project directory. To
108 * build the model for a POM from the repository, use {@link #setModelSource(ModelSource)} in combination with a
109 * {@link FileModelSource} instead.
110 *
111 * @param pomFile The POM file of the project to build the effective model for, may be {@code null} to build the
112 * model of some POM from the repository.
113 * @return This request, never {@code null}.
114 */
115 ModelBuildingRequest setPomFile(File pomFile);
116
117 /**
118 * Gets the level of validation to perform on processed models.
119 *
120 * @return The level of validation to perform on processed models.
121 */
122 int getValidationLevel();
123
124 /**
125 * Sets the level of validation to perform on processed models. For building of projects,
126 * {@link #VALIDATION_LEVEL_STRICT} should be used to ensure proper building. For the mere retrieval of dependencies
127 * during artifact resolution, {@link #VALIDATION_LEVEL_MINIMAL} should be used to account for models of poor
128 * quality. By default, models are validated in strict mode.
129 *
130 * @param validationLevel The level of validation to perform on processed models.
131 * @return This request, never {@code null}.
132 */
133 ModelBuildingRequest setValidationLevel(int validationLevel);
134
135 /**
136 * Indicates whether plugin executions and configurations should be processed. If enabled, lifecycle-induced plugin
137 * executions will be injected into the model and common plugin configuration will be propagated to individual
138 * executions.
139 *
140 * @return {@code true} if plugins should be processed, {@code false} otherwise.
141 */
142 boolean isProcessPlugins();
143
144 /**
145 * Controls the processing of plugin executions and configurations.
146 *
147 * @param processPlugins {@code true} to enable plugin processing, {@code false} otherwise.
148 * @return This request, never {@code null}.
149 */
150 ModelBuildingRequest setProcessPlugins(boolean processPlugins);
151
152 /**
153 * Indicates whether the model building should happen in two phases. If enabled, the initial invocation of the model
154 * builder will only produce an interim result which may be used to analyze inter-model dependencies before the
155 * final invocation of the model builder is performed.
156 *
157 * @return {@code true} if two-phase building is enabled, {@code false} if the model should be build in a single
158 * step.
159 */
160 boolean isTwoPhaseBuilding();
161
162 /**
163 * Enables/disables two-phase building. If enabled, the initial invocation of the model builder will only produce an
164 * interim result which may be used to analyze inter-model dependencies before the final invocation of the model
165 * builder is performed.
166 *
167 * @param twoPhaseBuilding {@code true} to enable two-phase building, {@code false} if the model should be build in
168 * a single step.
169 * @return This request, never {@code null}.
170 */
171 ModelBuildingRequest setTwoPhaseBuilding(boolean twoPhaseBuilding);
172
173 /**
174 * Indicates whether the model should track the line/column number of the model source from which it was parsed.
175 *
176 * @return {@code true} if location tracking is enabled, {@code false} otherwise.
177 */
178 boolean isLocationTracking();
179
180 /**
181 * Enables/disables the tracking of line/column numbers for the model source being parsed. By default, input
182 * locations are not tracked.
183 *
184 * @param locationTracking {@code true} to enable location tracking, {@code false} to disable it.
185 * @return This request, never {@code null}.
186 */
187 ModelBuildingRequest setLocationTracking(boolean locationTracking);
188
189 /**
190 * Gets the external profiles that should be considered for model building.
191 *
192 * @return The external profiles that should be considered for model building, never {@code null}.
193 */
194 List<Profile> getProfiles();
195
196 /**
197 * Sets the external profiles that should be considered for model building.
198 *
199 * @param profiles The external profiles that should be considered for model building, may be {@code null}.
200 * @return This request, never {@code null}.
201 */
202 ModelBuildingRequest setProfiles(List<Profile> profiles);
203
204 /**
205 * Gets the identifiers of those profiles that should be activated by explicit demand.
206 *
207 * @return The identifiers of those profiles to activate, never {@code null}.
208 */
209 List<String> getActiveProfileIds();
210
211 /**
212 * Sets the identifiers of those profiles that should be activated by explicit demand.
213 *
214 * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}.
215 * @return This request, never {@code null}.
216 */
217 ModelBuildingRequest setActiveProfileIds(List<String> activeProfileIds);
218
219 /**
220 * Gets the identifiers of those profiles that should be deactivated by explicit demand.
221 *
222 * @return The identifiers of those profiles to deactivate, never {@code null}.
223 */
224 List<String> getInactiveProfileIds();
225
226 /**
227 * Sets the identifiers of those profiles that should be deactivated by explicit demand.
228 *
229 * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}.
230 * @return This request, never {@code null}.
231 */
232 ModelBuildingRequest setInactiveProfileIds(List<String> inactiveProfileIds);
233
234 /**
235 * Gets the system properties to use for interpolation and profile activation. The system properties are collected
236 * from the runtime environment like {@link System#getProperties()} and environment variables.
237 *
238 * @return The system properties, never {@code null}.
239 */
240 Properties getSystemProperties();
241
242 /**
243 * Sets the system properties to use for interpolation and profile activation. The system properties are collected
244 * from the runtime environment like {@link System#getProperties()} and environment variables.
245 *
246 * @param systemProperties The system properties, may be {@code null}.
247 * @return This request, never {@code null}.
248 */
249 ModelBuildingRequest setSystemProperties(Properties systemProperties);
250
251 /**
252 * Gets the user properties to use for interpolation and profile activation. The user properties have been
253 * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command
254 * line.
255 *
256 * @return The user properties, never {@code null}.
257 */
258 Properties getUserProperties();
259
260 /**
261 * Sets the user properties to use for interpolation and profile activation. The user properties have been
262 * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command
263 * line.
264 *
265 * @param userProperties The user properties, may be {@code null}.
266 * @return This request, never {@code null}.
267 */
268 ModelBuildingRequest setUserProperties(Properties userProperties);
269
270 /**
271 * Gets the start time of the build.
272 *
273 * @return The start time of the build or {@code null} if unknown.
274 */
275 Date getBuildStartTime();
276
277 /**
278 * Sets the start time of the build.
279 *
280 * @param buildStartTime The start time of the build, may be {@code null}.
281 * @return This request, never {@code null}.
282 */
283 ModelBuildingRequest setBuildStartTime(Date buildStartTime);
284
285 /**
286 * Gets the model resolver to use for resolution of mixins or parents that are not locally reachable from the
287 * project directory.
288 *
289 * @return The model resolver or {@code null} if not set.
290 */
291 ModelResolver getModelResolver();
292
293 /**
294 * Sets the model resolver to use for resolution of mixins or parents that are not locally reachable from the
295 * project directory.
296 *
297 * @param modelResolver The model resolver to use, never {@code null}.
298 * @return This request, never {@code null}.
299 */
300 ModelBuildingRequest setModelResolver(ModelResolver modelResolver);
301
302 /**
303 * Gets the model building listener to notify during the build process.
304 *
305 * @return The model building listener to notify or {@code null} if none.
306 */
307 ModelBuildingListener getModelBuildingListener();
308
309 /**
310 * Sets the model building listener to notify during the build process.
311 *
312 * @param modelBuildingListener The model building listener to notify, may be {@code null}.
313 * @return This request, never {@code null}.
314 */
315 ModelBuildingRequest setModelBuildingListener(ModelBuildingListener modelBuildingListener);
316
317 /**
318 * Gets the model cache to use for reuse of previously built models.
319 *
320 * @return The model cache or {@code null} if not set.
321 */
322 ModelCache getModelCache();
323
324 /**
325 * Sets the model cache to use for reuse of previously built models. This is an optional component that serves
326 * performance optimizations.
327 *
328 * @param modelCache The model cache to use, may be {@code null}.
329 * @return This request, never {@code null}.
330 */
331 ModelBuildingRequest setModelCache(ModelCache modelCache);
332
333 WorkspaceModelResolver getWorkspaceModelResolver();
334
335 ModelBuildingRequest setWorkspaceModelResolver(WorkspaceModelResolver workspaceResolver);
336 }