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 1392618 2012-10-01 21:20:53Z rfscholte $
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<String> 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 File globalSettings;
74      
75      private File toolchains;
76  
77      private String globalChecksumPolicy;
78  
79      private String pomFilename;
80  
81      private File javaHome;
82  
83      private List<String> profiles;
84  
85      private boolean nonPluginUpdates;
86  
87      private Map<String, String> shellEnvironments;
88  
89      private String mavenOpts;
90      
91      private boolean activatedReactor;
92  
93      private String[] activatedReactorIncludes, activatedReactorExcludes;
94      
95      private List<String> projects;
96  
97      private boolean alsoMake;
98  
99      private boolean alsoMakeDependents;
100 
101     private String resumeFrom;
102 
103     private boolean showVersion;
104 
105     private String threads;
106 
107     public InvocationRequest activateReactor( String[] includes, String[] excludes )
108     {
109         activatedReactor = true;
110         activatedReactorIncludes = includes;
111         activatedReactorExcludes = excludes;
112         return this;
113     }
114 
115     public File getBaseDirectory()
116     {
117         return basedir;
118     }
119 
120     public File getBaseDirectory( File defaultDirectory )
121     {
122         return basedir == null ? defaultDirectory : basedir;
123     }
124 
125     public InvocationOutputHandler getErrorHandler( InvocationOutputHandler defaultHandler )
126     {
127         return errorHandler == null ? defaultHandler : errorHandler;
128     }
129 
130     public String getFailureBehavior()
131     {
132         return failureBehavior;
133     }
134 
135     public List<String> getGoals()
136     {
137         return goals;
138     }
139 
140     public InputStream getInputStream( InputStream defaultStream )
141     {
142         return inputStream == null ? defaultStream : inputStream;
143     }
144 
145     public File getLocalRepositoryDirectory( File defaultDirectory )
146     {
147         return localRepository == null ? defaultDirectory : localRepository;
148     }
149 
150     public InvocationOutputHandler getOutputHandler( InvocationOutputHandler defaultHandler )
151     {
152         return outputHandler == null ? defaultHandler : outputHandler;
153     }
154 
155     public File getPomFile()
156     {
157         return pomFile;
158     }
159 
160     public Properties getProperties()
161     {
162         return properties;
163     }
164 
165     public boolean isDebug()
166     {
167         return debug;
168     }
169 
170     public boolean isInteractive()
171     {
172         return interactive;
173     }
174 
175     public boolean isOffline()
176     {
177         return offline;
178     }
179 
180     public boolean isShowErrors()
181     {
182         return showErrors;
183     }
184 
185     public boolean isUpdateSnapshots()
186     {
187         return updateSnapshots;
188     }
189 
190     public boolean isRecursive()
191     {
192         return recursive;
193     }
194 
195     public InvocationRequest setRecursive( boolean recursive )
196     {
197         this.recursive = recursive;
198         return this;
199     }
200 
201     public InvocationRequest setBaseDirectory( File basedir )
202     {
203         this.basedir = basedir;
204         return this;
205     }
206 
207     public InvocationRequest setDebug( boolean debug )
208     {
209         this.debug = debug;
210         return this;
211     }
212 
213     public InvocationRequest setErrorHandler( InvocationOutputHandler errorHandler )
214     {
215         this.errorHandler = errorHandler;
216         return this;
217     }
218 
219     public InvocationRequest setFailureBehavior( String failureBehavior )
220     {
221         this.failureBehavior = failureBehavior;
222         return this;
223     }
224 
225     public InvocationRequest setGoals( List<String> goals )
226     {
227         this.goals = goals;
228         return this;
229     }
230 
231     public InvocationRequest setInputStream( InputStream inputStream )
232     {
233         this.inputStream = inputStream;
234         return this;
235     }
236 
237     public InvocationRequest setInteractive( boolean interactive )
238     {
239         this.interactive = interactive;
240         return this;
241     }
242 
243     public InvocationRequest setLocalRepositoryDirectory( File localRepository )
244     {
245         this.localRepository = localRepository;
246         return this;
247     }
248 
249     public InvocationRequest setOffline( boolean offline )
250     {
251         this.offline = offline;
252         return this;
253     }
254 
255     public InvocationRequest setOutputHandler( InvocationOutputHandler outputHandler )
256     {
257         this.outputHandler = outputHandler;
258         return this;
259     }
260 
261     public InvocationRequest setPomFile( File pomFile )
262     {
263         this.pomFile = pomFile;
264         return this;
265     }
266 
267     public InvocationRequest setProperties( Properties properties )
268     {
269         this.properties = properties;
270         return this;
271     }
272 
273     public InvocationRequest setShowErrors( boolean showErrors )
274     {
275         this.showErrors = showErrors;
276         return this;
277     }
278 
279     public InvocationRequest setUpdateSnapshots( boolean updateSnapshots )
280     {
281         this.updateSnapshots = updateSnapshots;
282         return this;
283     }
284 
285     public boolean isShellEnvironmentInherited()
286     {
287         return shellEnvironmentInherited;
288     }
289 
290     public InvocationRequest setShellEnvironmentInherited( boolean shellEnvironmentInherited )
291     {
292         this.shellEnvironmentInherited = shellEnvironmentInherited;
293         return this;
294     }
295 
296     public File getJavaHome()
297     {
298         return javaHome;
299     }
300 
301     public InvocationRequest setJavaHome( File javaHome )
302     {
303         this.javaHome = javaHome;
304         return this;
305     }
306 
307     public File getUserSettingsFile()
308     {
309         return userSettings;
310     }
311     
312     public InvocationRequest setUserSettingsFile( File userSettings )
313     {
314         this.userSettings = userSettings;
315         return this;
316     }
317 
318     public File getGlobalSettingsFile()
319     {
320         return globalSettings;
321     }
322 
323     public InvocationRequest setGlobalSettingsFile( File globalSettings )
324     {
325         this.globalSettings = globalSettings;
326         return this;
327     }
328 
329     public File getToolchainsFile()
330     {
331         return toolchains;
332     }
333     
334     public InvocationRequest setToolchainsFile( File toolchains )
335     {
336         this.toolchains = toolchains;
337         return this;
338     }
339     
340     public String getGlobalChecksumPolicy()
341     {
342         return globalChecksumPolicy;
343     }
344 
345     public InvocationRequest setGlobalChecksumPolicy( String globalChecksumPolicy )
346     {
347         this.globalChecksumPolicy = globalChecksumPolicy;
348         return this;
349     }
350 
351     public String getPomFileName()
352     {
353         return pomFilename;
354     }
355 
356     public InvocationRequest setPomFileName( String pomFilename )
357     {
358         this.pomFilename = pomFilename;
359         return this;
360     }
361 
362     public List<String> getProfiles()
363     {
364         return profiles;
365     }
366 
367     public InvocationRequest setProfiles( List<String> profiles )
368     {
369         this.profiles = profiles;
370         return this;
371     }
372 
373     public boolean isNonPluginUpdates()
374     {
375         return nonPluginUpdates;
376     }
377 
378     public InvocationRequest setNonPluginUpdates( boolean nonPluginUpdates )
379     {
380         this.nonPluginUpdates = nonPluginUpdates;
381         return this;
382     }
383 
384     public InvocationRequest addShellEnvironment( String name, String value )
385     {
386         if ( this.shellEnvironmentInherited )
387         {
388             this.shellEnvironments = new HashMap<String, String>();
389         }
390         this.shellEnvironments.put( name, value );
391         return this;
392     }
393 
394     public Map<String, String> getShellEnvironments()
395     {
396         return shellEnvironments == null ? Collections.<String, String>emptyMap(): shellEnvironments;
397     }
398 
399     public String getMavenOpts()
400     {
401         return mavenOpts;
402     }
403 
404     public InvocationRequest setMavenOpts( String mavenOpts )
405     {
406         this.mavenOpts = mavenOpts;
407         return this;
408     }
409     
410     public boolean isActivatedReactor()
411     {
412         return activatedReactor;
413     }
414 
415     public String[] getActivatedReactorIncludes()
416     {
417         return activatedReactorIncludes;
418     }
419 
420     public String[] getActivatedReactorExcludes()
421     {
422         return activatedReactorExcludes;
423     }
424 
425     /**
426      * @see org.apache.maven.shared.invoker.InvocationRequest#isShowVersion()
427      */
428     public boolean isShowVersion()
429     {
430         return this.showVersion;
431     }
432 
433     /**
434      * @see org.apache.maven.shared.invoker.InvocationRequest#setShowVersion(boolean)
435      */
436     public InvocationRequest setShowVersion( boolean showVersion )
437     {
438         this.showVersion = showVersion;
439         return this;
440     }
441     
442     /**
443      * {@inheritDoc}
444      */
445     public String getThreads()
446     {
447         return threads;
448     }
449     
450     /**
451      * {@inheritDoc}
452      */
453     public InvocationRequest setThreads( String threads )
454     {
455         this.threads = threads;
456         return this;
457     }
458 
459     /**
460      * {@inheritDoc}
461      */
462     public List<String> getProjects()
463     {
464         return projects;
465     }
466 
467     /**
468      * {@inheritDoc}
469      */
470     public InvocationRequest setProjects( List<String> projects )
471     {
472         this.projects = projects;
473         return this;
474     }
475 
476     /**
477      * {@inheritDoc}
478      */
479     public boolean isAlsoMake()
480     {
481         return alsoMake;
482     }
483 
484     /**
485      * {@inheritDoc}
486      */
487     public InvocationRequest setAlsoMake( boolean alsoMake )
488     {
489         this.alsoMake = alsoMake;
490         return this;
491     }
492 
493     /**
494      * {@inheritDoc}
495      */
496     public boolean isAlsoMakeDependents()
497     {
498         return alsoMakeDependents;
499     }
500 
501     /**
502      * {@inheritDoc}
503      */
504     public InvocationRequest setAlsoMakeDependents( boolean alsoMakeDependents )
505     {
506         this.alsoMakeDependents = alsoMakeDependents;
507         return this;
508     }
509 
510     /**
511      * {@inheritDoc}
512      */
513     public String getResumeFrom()
514     {
515         return resumeFrom;
516     }
517 
518     /**
519      * {@inheritDoc}
520      */
521     public InvocationRequest setResumeFrom( String resumeFrom )
522     {
523         this.resumeFrom = resumeFrom;
524         return this;
525     }
526     
527 }