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