1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  package org.apache.maven.shared.invoker;
20  
21  import java.io.File;
22  import java.io.InputStream;
23  import java.util.ArrayList;
24  import java.util.Collection;
25  import java.util.Collections;
26  import java.util.HashMap;
27  import java.util.List;
28  import java.util.Map;
29  import java.util.Properties;
30  
31  
32  
33  
34  
35  public class DefaultInvocationRequest implements InvocationRequest {
36  
37      private File basedir;
38  
39      private boolean debug;
40  
41      private InvocationOutputHandler errorHandler;
42  
43      private ReactorFailureBehavior failureBehavior = ReactorFailureBehavior.FailFast;
44  
45      private List<String> goals;
46  
47      private InputStream inputStream;
48  
49      private boolean interactive;
50  
51      private File localRepository;
52  
53      private boolean offline;
54  
55      private boolean recursive = true;
56  
57      private InvocationOutputHandler outputHandler;
58  
59      private File pomFile;
60  
61      private Properties properties;
62  
63      private boolean showErrors;
64  
65      private UpdateSnapshotsPolicy updateSnapshotsPolicy = UpdateSnapshotsPolicy.DEFAULT;
66  
67      private boolean shellEnvironmentInherited = true;
68  
69      private File userSettings;
70  
71      private File globalSettings;
72  
73      private File toolchains;
74  
75      private File globalToolchains;
76  
77      private CheckSumPolicy 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 List<String> projects;
92  
93      private boolean alsoMake;
94  
95      private boolean alsoMakeDependents;
96  
97      private String resumeFrom;
98  
99      private boolean showVersion;
100 
101     private String threads;
102 
103     private String builderId;
104 
105     private int timeoutInSeconds = NO_TIMEOUT;
106 
107     private boolean quiet;
108 
109     private File mavenHome;
110 
111     private File mavenExecutable;
112 
113     private boolean noTransferProgress;
114 
115     private List<String> args = new ArrayList<>();
116 
117     
118 
119 
120 
121 
122     public File getBaseDirectory() {
123         return basedir;
124     }
125 
126     
127     public File getBaseDirectory(File defaultDirectory) {
128         return basedir == null ? defaultDirectory : basedir;
129     }
130 
131     
132     public InvocationOutputHandler getErrorHandler(InvocationOutputHandler defaultHandler) {
133         return errorHandler == null ? defaultHandler : errorHandler;
134     }
135 
136     
137 
138 
139 
140 
141     public ReactorFailureBehavior getReactorFailureBehavior() {
142         return failureBehavior;
143     }
144 
145     
146 
147 
148 
149 
150     public List<String> getGoals() {
151         return goals;
152     }
153 
154     
155     public InputStream getInputStream(InputStream defaultStream) {
156         return inputStream == null ? defaultStream : inputStream;
157     }
158 
159     
160     public File getLocalRepositoryDirectory(File defaultDirectory) {
161         return localRepository == null ? defaultDirectory : localRepository;
162     }
163 
164     
165     public InvocationOutputHandler getOutputHandler(InvocationOutputHandler defaultHandler) {
166         return outputHandler == null ? defaultHandler : outputHandler;
167     }
168 
169     
170 
171 
172 
173 
174     public File getPomFile() {
175         return pomFile;
176     }
177 
178     
179 
180 
181 
182 
183     public Properties getProperties() {
184         return properties;
185     }
186 
187     
188 
189 
190 
191 
192     public boolean isDebug() {
193         return debug;
194     }
195 
196     
197 
198 
199 
200 
201     public boolean isBatchMode() {
202         return interactive;
203     }
204 
205     
206 
207 
208 
209 
210     public boolean isOffline() {
211         return offline;
212     }
213 
214     
215 
216 
217 
218 
219     public boolean isShowErrors() {
220         return showErrors;
221     }
222 
223     
224 
225 
226 
227 
228     public boolean isUpdateSnapshots() {
229         return updateSnapshotsPolicy == UpdateSnapshotsPolicy.ALWAYS;
230     }
231 
232     public UpdateSnapshotsPolicy getUpdateSnapshotsPolicy() {
233         return updateSnapshotsPolicy;
234     }
235 
236     
237 
238 
239 
240 
241     public boolean isRecursive() {
242         return recursive;
243     }
244 
245     
246     public InvocationRequest setRecursive(boolean recursive) {
247         this.recursive = recursive;
248         return this;
249     }
250 
251     
252     public InvocationRequest setBaseDirectory(File basedir) {
253         this.basedir = basedir;
254         return this;
255     }
256 
257     
258     public InvocationRequest setDebug(boolean debug) {
259         this.debug = debug;
260         return this;
261     }
262 
263     
264     public InvocationRequest setErrorHandler(InvocationOutputHandler errorHandler) {
265         this.errorHandler = errorHandler;
266         return this;
267     }
268 
269     
270 
271 
272 
273 
274 
275     public InvocationRequest setReactorFailureBehavior(ReactorFailureBehavior failureBehavior) {
276         this.failureBehavior = failureBehavior;
277         return this;
278     }
279 
280     
281     public InvocationRequest setGoals(List<String> goals) {
282         this.goals = goals;
283         return this;
284     }
285 
286     
287     public InvocationRequest setInputStream(InputStream inputStream) {
288         this.inputStream = inputStream;
289         return this;
290     }
291 
292     
293     public InvocationRequest setBatchMode(boolean interactive) {
294         this.interactive = interactive;
295         return this;
296     }
297 
298     
299     public InvocationRequest setLocalRepositoryDirectory(File localRepository) {
300         this.localRepository = localRepository;
301         return this;
302     }
303 
304     
305     public InvocationRequest setOffline(boolean offline) {
306         this.offline = offline;
307         return this;
308     }
309 
310     
311     public InvocationRequest setOutputHandler(InvocationOutputHandler outputHandler) {
312         this.outputHandler = outputHandler;
313         return this;
314     }
315 
316     
317     public InvocationRequest setPomFile(File pomFile) {
318         this.pomFile = pomFile;
319         return this;
320     }
321 
322     
323     public InvocationRequest setProperties(Properties properties) {
324         this.properties = properties;
325         return this;
326     }
327 
328     
329     public InvocationRequest setShowErrors(boolean showErrors) {
330         this.showErrors = showErrors;
331         return this;
332     }
333 
334     
335     public InvocationRequest setUpdateSnapshots(boolean updateSnapshots) {
336         return setUpdateSnapshotsPolicy(updateSnapshots ? UpdateSnapshotsPolicy.ALWAYS : UpdateSnapshotsPolicy.DEFAULT);
337     }
338 
339     @Override
340     public InvocationRequest setUpdateSnapshotsPolicy(UpdateSnapshotsPolicy policy) {
341         this.updateSnapshotsPolicy = policy;
342         return this;
343     }
344 
345     
346 
347 
348 
349 
350 
351     public boolean isShellEnvironmentInherited() {
352         return shellEnvironmentInherited;
353     }
354 
355     
356     public InvocationRequest setShellEnvironmentInherited(boolean shellEnvironmentInherited) {
357         this.shellEnvironmentInherited = shellEnvironmentInherited;
358         return this;
359     }
360 
361     
362 
363 
364 
365 
366     public File getJavaHome() {
367         return javaHome;
368     }
369 
370     
371     public InvocationRequest setJavaHome(File javaHome) {
372         this.javaHome = javaHome;
373         return this;
374     }
375 
376     
377 
378 
379 
380 
381     public File getUserSettingsFile() {
382         return userSettings;
383     }
384 
385     
386     public InvocationRequest setUserSettingsFile(File userSettings) {
387         this.userSettings = userSettings;
388         return this;
389     }
390 
391     
392 
393 
394 
395 
396     public File getGlobalSettingsFile() {
397         return globalSettings;
398     }
399 
400     
401     public InvocationRequest setGlobalSettingsFile(File globalSettings) {
402         this.globalSettings = globalSettings;
403         return this;
404     }
405 
406     
407 
408 
409 
410 
411     public File getToolchainsFile() {
412         return toolchains;
413     }
414 
415     
416     public InvocationRequest setToolchainsFile(File toolchains) {
417         this.toolchains = toolchains;
418         return this;
419     }
420 
421     
422 
423 
424 
425 
426     public File getGlobalToolchainsFile() {
427         return globalToolchains;
428     }
429 
430     
431     public InvocationRequest setGlobalToolchainsFile(File toolchains) {
432         this.globalToolchains = toolchains;
433         return this;
434     }
435 
436     
437 
438 
439 
440 
441     public CheckSumPolicy getGlobalChecksumPolicy() {
442         return globalChecksumPolicy;
443     }
444 
445     
446 
447 
448 
449 
450 
451     public InvocationRequest setGlobalChecksumPolicy(CheckSumPolicy globalChecksumPolicy) {
452         this.globalChecksumPolicy = globalChecksumPolicy;
453         return this;
454     }
455 
456     
457 
458 
459 
460 
461     public String getPomFileName() {
462         return pomFilename;
463     }
464 
465     @Override
466     public InvocationRequest addArg(String arg) {
467         args.add(arg);
468         return this;
469     }
470 
471     @Override
472     public InvocationRequest addArgs(Collection<String> args) {
473         this.args.addAll(args);
474         return this;
475     }
476 
477     public List<String> getArgs() {
478         return args;
479     }
480 
481     
482     public InvocationRequest setPomFileName(String pomFilename) {
483         this.pomFilename = pomFilename;
484         return this;
485     }
486 
487     
488 
489 
490 
491 
492     public List<String> getProfiles() {
493         return profiles;
494     }
495 
496     
497     public InvocationRequest setProfiles(List<String> profiles) {
498         this.profiles = profiles;
499         return this;
500     }
501 
502     
503 
504 
505 
506 
507     public boolean isNonPluginUpdates() {
508         return nonPluginUpdates;
509     }
510 
511     
512     public InvocationRequest setNonPluginUpdates(boolean nonPluginUpdates) {
513         this.nonPluginUpdates = nonPluginUpdates;
514         return this;
515     }
516 
517     
518     public InvocationRequest addShellEnvironment(String name, String value) {
519         if (this.shellEnvironments == null) {
520             this.shellEnvironments = new HashMap<>();
521         }
522         this.shellEnvironments.put(name, value);
523         return this;
524     }
525 
526     
527 
528 
529 
530 
531     public Map<String, String> getShellEnvironments() {
532         return shellEnvironments == null ? Collections.<String, String>emptyMap() : shellEnvironments;
533     }
534 
535     
536 
537 
538 
539 
540     public String getMavenOpts() {
541         return mavenOpts;
542     }
543 
544     
545     public InvocationRequest setMavenOpts(String mavenOpts) {
546         this.mavenOpts = mavenOpts;
547         return this;
548     }
549 
550     
551 
552 
553 
554 
555 
556     public boolean isShowVersion() {
557         return this.showVersion;
558     }
559 
560     
561     public InvocationRequest setShowVersion(boolean showVersion) {
562         this.showVersion = showVersion;
563         return this;
564     }
565 
566     
567 
568 
569 
570 
571     public String getThreads() {
572         return threads;
573     }
574 
575     
576     public InvocationRequest setThreads(String threads) {
577         this.threads = threads;
578         return this;
579     }
580 
581     
582 
583 
584 
585 
586     public List<String> getProjects() {
587         return projects;
588     }
589 
590     
591     public InvocationRequest setProjects(List<String> projects) {
592         this.projects = projects;
593         return this;
594     }
595 
596     
597 
598 
599 
600 
601     public boolean isAlsoMake() {
602         return alsoMake;
603     }
604 
605     
606     public InvocationRequest setAlsoMake(boolean alsoMake) {
607         this.alsoMake = alsoMake;
608         return this;
609     }
610 
611     
612 
613 
614 
615 
616     public boolean isAlsoMakeDependents() {
617         return alsoMakeDependents;
618     }
619 
620     
621     public InvocationRequest setAlsoMakeDependents(boolean alsoMakeDependents) {
622         this.alsoMakeDependents = alsoMakeDependents;
623         return this;
624     }
625 
626     
627 
628 
629 
630 
631     public String getResumeFrom() {
632         return resumeFrom;
633     }
634 
635     
636     public InvocationRequest setResumeFrom(String resumeFrom) {
637         this.resumeFrom = resumeFrom;
638         return this;
639     }
640 
641     
642     public InvocationRequest setBuilder(String id) {
643         this.builderId = id;
644         return this;
645     }
646 
647     
648 
649 
650 
651 
652     public String getBuilder() {
653         return this.builderId;
654     }
655 
656     
657     @Override
658     public int getTimeoutInSeconds() {
659         return timeoutInSeconds;
660     }
661 
662     
663     @Override
664     public void setTimeoutInSeconds(int timeoutInSeconds) {
665         this.timeoutInSeconds = timeoutInSeconds;
666     }
667 
668     
669 
670 
671 
672 
673 
674     public boolean isQuiet() {
675         return quiet;
676     }
677 
678     
679     public InvocationRequest setQuiet(boolean quiet) {
680         this.quiet = quiet;
681         return this;
682     }
683 
684     @Override
685     public boolean isNoTransferProgress() {
686         return noTransferProgress;
687     }
688 
689     @Override
690     public InvocationRequest setNoTransferProgress(boolean noTransferProgress) {
691         this.noTransferProgress = noTransferProgress;
692         return this;
693     }
694 
695     
696 
697 
698     @Override
699     public File getMavenHome() {
700         return mavenHome;
701     }
702 
703     
704 
705 
706     @Override
707     public InvocationRequest setMavenHome(File mavenHome) {
708         this.mavenHome = mavenHome;
709         return this;
710     }
711 
712     
713 
714 
715     @Override
716     public File getMavenExecutable() {
717         return mavenExecutable;
718     }
719 
720     
721 
722 
723     @Override
724     public InvocationRequest setMavenExecutable(File mavenExecutable) {
725         this.mavenExecutable = mavenExecutable;
726         return this;
727     }
728 }