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