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.ArrayList;
24  import java.util.Date;
25  import java.util.List;
26  import java.util.Properties;
27  
28  import org.apache.maven.model.Profile;
29  import org.apache.maven.model.resolution.ModelResolver;
30  
31  /**
32   * Collects settings that control building of effective models.
33   * 
34   * @author Benjamin Bentmann
35   */
36  public class DefaultModelBuildingRequest
37      implements ModelBuildingRequest
38  {
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      /**
71       * Creates an empty request.
72       */
73      public DefaultModelBuildingRequest()
74      {
75      }
76  
77      /**
78       * Creates a shallow copy of the specified request.
79       * 
80       * @param request The request to copy, must not be {@code null}.
81       */
82      public DefaultModelBuildingRequest( ModelBuildingRequest request )
83      {
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      }
99  
100     public File getPomFile()
101     {
102         return pomFile;
103     }
104 
105     public DefaultModelBuildingRequest setPomFile( File pomFile )
106     {
107         this.pomFile = ( pomFile != null ) ? pomFile.getAbsoluteFile() : null;
108 
109         return this;
110     }
111 
112     public ModelSource getModelSource()
113     {
114         return modelSource;
115     }
116 
117     public DefaultModelBuildingRequest setModelSource( ModelSource modelSource )
118     {
119         this.modelSource = modelSource;
120 
121         return this;
122     }
123 
124     public int getValidationLevel()
125     {
126         return validationLevel;
127     }
128 
129     public DefaultModelBuildingRequest setValidationLevel( int validationLevel )
130     {
131         this.validationLevel = validationLevel;
132 
133         return this;
134     }
135 
136     public boolean isProcessPlugins()
137     {
138         return processPlugins;
139     }
140 
141     public DefaultModelBuildingRequest setProcessPlugins( boolean processPlugins )
142     {
143         this.processPlugins = processPlugins;
144 
145         return this;
146     }
147 
148     public boolean isTwoPhaseBuilding()
149     {
150         return twoPhaseBuilding;
151     }
152 
153     public DefaultModelBuildingRequest setTwoPhaseBuilding( boolean twoPhaseBuilding )
154     {
155         this.twoPhaseBuilding = twoPhaseBuilding;
156 
157         return this;
158     }
159 
160     public boolean isLocationTracking()
161     {
162         return locationTracking;
163     }
164 
165     public DefaultModelBuildingRequest setLocationTracking( boolean locationTracking )
166     {
167         this.locationTracking = locationTracking;
168 
169         return this;
170     }
171 
172     public List<Profile> getProfiles()
173     {
174         if ( profiles == null )
175         {
176             profiles = new ArrayList<Profile>();
177         }
178 
179         return profiles;
180     }
181 
182     public DefaultModelBuildingRequest setProfiles( List<Profile> profiles )
183     {
184         if ( profiles != null )
185         {
186             this.profiles = new ArrayList<Profile>( profiles );
187         }
188         else
189         {
190             this.profiles = null;
191         }
192 
193         return this;
194     }
195 
196     public List<String> getActiveProfileIds()
197     {
198         if ( activeProfileIds == null )
199         {
200             activeProfileIds = new ArrayList<String>();
201         }
202 
203         return activeProfileIds;
204     }
205 
206     public DefaultModelBuildingRequest setActiveProfileIds( List<String> activeProfileIds )
207     {
208         if ( activeProfileIds != null )
209         {
210             this.activeProfileIds = new ArrayList<String>( activeProfileIds );
211         }
212         else
213         {
214             this.activeProfileIds = null;
215         }
216 
217         return this;
218     }
219 
220     public List<String> getInactiveProfileIds()
221     {
222         if ( inactiveProfileIds == null )
223         {
224             inactiveProfileIds = new ArrayList<String>();
225         }
226 
227         return inactiveProfileIds;
228     }
229 
230     public DefaultModelBuildingRequest setInactiveProfileIds( List<String> inactiveProfileIds )
231     {
232         if ( inactiveProfileIds != null )
233         {
234             this.inactiveProfileIds = new ArrayList<String>( inactiveProfileIds );
235         }
236         else
237         {
238             this.inactiveProfileIds = null;
239         }
240 
241         return this;
242     }
243 
244     public Properties getSystemProperties()
245     {
246         if ( systemProperties == null )
247         {
248             systemProperties = new Properties();
249         }
250 
251         return systemProperties;
252     }
253 
254     public DefaultModelBuildingRequest setSystemProperties( Properties systemProperties )
255     {
256         if ( systemProperties != null )
257         {
258             this.systemProperties = new Properties();
259             this.systemProperties.putAll( systemProperties );
260         }
261         else
262         {
263             this.systemProperties = null;
264         }
265 
266         return this;
267     }
268 
269     public Properties getUserProperties()
270     {
271         if ( userProperties == null )
272         {
273             userProperties = new Properties();
274         }
275 
276         return userProperties;
277     }
278 
279     public DefaultModelBuildingRequest setUserProperties( Properties userProperties )
280     {
281         if ( userProperties != null )
282         {
283             this.userProperties = new Properties();
284             this.userProperties.putAll( userProperties );
285         }
286         else
287         {
288             this.userProperties = null;
289         }
290 
291         return this;
292     }
293 
294     public Date getBuildStartTime()
295     {
296         return buildStartTime;
297     }
298 
299     public ModelBuildingRequest setBuildStartTime( Date buildStartTime )
300     {
301         this.buildStartTime = buildStartTime;
302 
303         return this;
304     }
305 
306     public ModelResolver getModelResolver()
307     {
308         return this.modelResolver;
309     }
310 
311     public DefaultModelBuildingRequest setModelResolver( ModelResolver modelResolver )
312     {
313         this.modelResolver = modelResolver;
314 
315         return this;
316     }
317 
318     public ModelBuildingListener getModelBuildingListener()
319     {
320         return modelBuildingListener;
321     }
322 
323     public ModelBuildingRequest setModelBuildingListener( ModelBuildingListener modelBuildingListener )
324     {
325         this.modelBuildingListener = modelBuildingListener;
326 
327         return this;
328     }
329 
330     public ModelCache getModelCache()
331     {
332         return this.modelCache;
333     }
334 
335     public DefaultModelBuildingRequest setModelCache( ModelCache modelCache )
336     {
337         this.modelCache = modelCache;
338 
339         return this;
340     }
341 
342 }