View Javadoc

1   package org.apache.maven.shared.invoker;
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.io.InputStream;
24  import java.util.Collections;
25  import java.util.HashMap;
26  import java.util.List;
27  import java.util.Map;
28  import java.util.Properties;
29  
30  /**
31   * Specifies the parameters used to control a Maven invocation.
32   * 
33   * @version $Id: DefaultInvocationRequest.java 807415 2009-08-24 22:32:16Z olamy $
34   */
35  public class DefaultInvocationRequest
36      implements InvocationRequest
37  {
38  
39      private File basedir;
40  
41      private boolean debug;
42  
43      private InvocationOutputHandler errorHandler;
44  
45      private String failureBehavior = REACTOR_FAIL_FAST;
46  
47      private List goals;
48  
49      private InputStream inputStream;
50  
51      private boolean interactive;
52  
53      private File localRepository;
54  
55      private boolean offline;
56  
57      private boolean recursive = true;
58  
59      private InvocationOutputHandler outputHandler;
60  
61      private File pomFile;
62  
63      private Properties properties;
64  
65      private boolean showErrors;
66  
67      private boolean updateSnapshots;
68  
69      private boolean shellEnvironmentInherited = true;
70  
71      private File userSettings;
72  
73      private String globalChecksumPolicy;
74  
75      private String pomFilename;
76  
77      private File javaHome;
78  
79      private List profiles;
80  
81      private boolean nonPluginUpdates;
82  
83      private Map shellEnvironments;
84  
85      private String mavenOpts;
86      
87      private boolean activatedReactor;
88  
89      private String[] activatedReactorIncludes, activatedReactorExcludes;
90      
91      private boolean showVersion;
92  
93      public InvocationRequest activateReactor( String[] includes, String[] excludes )
94      {
95          activatedReactor = true;
96          activatedReactorIncludes = includes;
97          activatedReactorExcludes = excludes;
98          return this;
99      }
100 
101     public File getBaseDirectory()
102     {
103         return basedir;
104     }
105 
106     public File getBaseDirectory( File defaultDirectory )
107     {
108         return basedir == null ? defaultDirectory : basedir;
109     }
110 
111     public InvocationOutputHandler getErrorHandler( InvocationOutputHandler defaultHandler )
112     {
113         return errorHandler == null ? defaultHandler : errorHandler;
114     }
115 
116     public String getFailureBehavior()
117     {
118         return failureBehavior;
119     }
120 
121     public List getGoals()
122     {
123         return goals;
124     }
125 
126     public InputStream getInputStream( InputStream defaultStream )
127     {
128         return inputStream == null ? defaultStream : inputStream;
129     }
130 
131     public File getLocalRepositoryDirectory( File defaultDirectory )
132     {
133         return localRepository == null ? defaultDirectory : localRepository;
134     }
135 
136     public InvocationOutputHandler getOutputHandler( InvocationOutputHandler defaultHandler )
137     {
138         return outputHandler == null ? defaultHandler : outputHandler;
139     }
140 
141     public File getPomFile()
142     {
143         return pomFile;
144     }
145 
146     public Properties getProperties()
147     {
148         return properties;
149     }
150 
151     public boolean isDebug()
152     {
153         return debug;
154     }
155 
156     public boolean isInteractive()
157     {
158         return interactive;
159     }
160 
161     public boolean isOffline()
162     {
163         return offline;
164     }
165 
166     public boolean isShowErrors()
167     {
168         return showErrors;
169     }
170 
171     public boolean isUpdateSnapshots()
172     {
173         return updateSnapshots;
174     }
175 
176     public boolean isRecursive()
177     {
178         return recursive;
179     }
180 
181     public InvocationRequest setRecursive( boolean recursive )
182     {
183         this.recursive = recursive;
184         return this;
185     }
186 
187     public InvocationRequest setBaseDirectory( File basedir )
188     {
189         this.basedir = basedir;
190         return this;
191     }
192 
193     public InvocationRequest setDebug( boolean debug )
194     {
195         this.debug = debug;
196         return this;
197     }
198 
199     public InvocationRequest setErrorHandler( InvocationOutputHandler errorHandler )
200     {
201         this.errorHandler = errorHandler;
202         return this;
203     }
204 
205     public InvocationRequest setFailureBehavior( String failureBehavior )
206     {
207         this.failureBehavior = failureBehavior;
208         return this;
209     }
210 
211     public InvocationRequest setGoals( List goals )
212     {
213         this.goals = goals;
214         return this;
215     }
216 
217     public InvocationRequest setInputStream( InputStream inputStream )
218     {
219         this.inputStream = inputStream;
220         return this;
221     }
222 
223     public InvocationRequest setInteractive( boolean interactive )
224     {
225         this.interactive = interactive;
226         return this;
227     }
228 
229     public InvocationRequest setLocalRepositoryDirectory( File localRepository )
230     {
231         this.localRepository = localRepository;
232         return this;
233     }
234 
235     public InvocationRequest setOffline( boolean offline )
236     {
237         this.offline = offline;
238         return this;
239     }
240 
241     public InvocationRequest setOutputHandler( InvocationOutputHandler outputHandler )
242     {
243         this.outputHandler = outputHandler;
244         return this;
245     }
246 
247     public InvocationRequest setPomFile( File pomFile )
248     {
249         this.pomFile = pomFile;
250         return this;
251     }
252 
253     public InvocationRequest setProperties( Properties properties )
254     {
255         this.properties = properties;
256         return this;
257     }
258 
259     public InvocationRequest setShowErrors( boolean showErrors )
260     {
261         this.showErrors = showErrors;
262         return this;
263     }
264 
265     public InvocationRequest setUpdateSnapshots( boolean updateSnapshots )
266     {
267         this.updateSnapshots = updateSnapshots;
268         return this;
269     }
270 
271     public boolean isShellEnvironmentInherited()
272     {
273         return shellEnvironmentInherited;
274     }
275 
276     public InvocationRequest setShellEnvironmentInherited( boolean shellEnvironmentInherited )
277     {
278         this.shellEnvironmentInherited = shellEnvironmentInherited;
279         return this;
280     }
281 
282     public File getJavaHome()
283     {
284         return javaHome;
285     }
286 
287     public InvocationRequest setJavaHome( File javaHome )
288     {
289         this.javaHome = javaHome;
290         return this;
291     }
292 
293     public File getUserSettingsFile()
294     {
295         return userSettings;
296     }
297 
298     public InvocationRequest setUserSettingsFile( File userSettings )
299     {
300         this.userSettings = userSettings;
301         return this;
302     }
303 
304     public String getGlobalChecksumPolicy()
305     {
306         return globalChecksumPolicy;
307     }
308 
309     public InvocationRequest setGlobalChecksumPolicy( String globalChecksumPolicy )
310     {
311         this.globalChecksumPolicy = globalChecksumPolicy;
312         return this;
313     }
314 
315     public String getPomFileName()
316     {
317         return pomFilename;
318     }
319 
320     public InvocationRequest setPomFileName( String pomFilename )
321     {
322         this.pomFilename = pomFilename;
323         return this;
324     }
325 
326     public List getProfiles()
327     {
328         return profiles;
329     }
330 
331     public InvocationRequest setProfiles( List profiles )
332     {
333         this.profiles = profiles;
334         return this;
335     }
336 
337     public boolean isNonPluginUpdates()
338     {
339         return nonPluginUpdates;
340     }
341 
342     public InvocationRequest setNonPluginUpdates( boolean nonPluginUpdates )
343     {
344         this.nonPluginUpdates = nonPluginUpdates;
345         return this;
346     }
347 
348     public InvocationRequest addShellEnvironment( String name, String value )
349     {
350         if ( this.shellEnvironmentInherited )
351         {
352             this.shellEnvironments = new HashMap();
353         }
354         this.shellEnvironments.put( name, value );
355         return this;
356     }
357 
358     public Map getShellEnvironments()
359     {
360         return shellEnvironments == null ? Collections.EMPTY_MAP : shellEnvironments;
361     }
362 
363     public String getMavenOpts()
364     {
365         return mavenOpts;
366     }
367 
368     public InvocationRequest setMavenOpts( String mavenOpts )
369     {
370         this.mavenOpts = mavenOpts;
371         return this;
372     }
373     
374     public boolean isActivatedReactor()
375     {
376         return activatedReactor;
377     }
378 
379     public String[] getActivatedReactorIncludes()
380     {
381         return activatedReactorIncludes;
382     }
383 
384     public String[] getActivatedReactorExcludes()
385     {
386         return activatedReactorExcludes;
387     }
388 
389     /**
390      * @see org.apache.maven.shared.invoker.InvocationRequest#isShowVersion()
391      */
392     public boolean isShowVersion()
393     {
394         return this.showVersion;
395     }
396 
397     /**
398      * @see org.apache.maven.shared.invoker.InvocationRequest#setShowVersion(boolean)
399      */
400     public InvocationRequest setShowVersion( boolean showVersion )
401     {
402         this.showVersion = showVersion;
403         return this;
404     }
405 
406 }