1
2
3
4
5 package org.apache.maven.api.plugin.descriptor;
6
7 import java.io.Serializable;
8 import java.util.ArrayList;
9 import java.util.Collection;
10 import java.util.Collections;
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14 import org.apache.maven.api.annotations.Experimental;
15 import org.apache.maven.api.annotations.Generated;
16 import org.apache.maven.api.annotations.Immutable;
17 import org.apache.maven.api.annotations.Nonnull;
18 import org.apache.maven.api.annotations.NotThreadSafe;
19 import org.apache.maven.api.annotations.ThreadSafe;
20
21
22
23
24 @Experimental
25 @Generated @ThreadSafe @Immutable
26 public class MojoDescriptor
27 implements Serializable
28 {
29
30
31
32
33 final String goal;
34
35
36
37 final String description;
38
39
40
41 final String implementation;
42
43
44
45 final String language;
46
47
48
49
50
51
52 final String phase;
53
54
55
56 final String executePhase;
57
58
59
60 final String executeGoal;
61
62
63
64 final String executeLifecycle;
65
66
67
68
69
70 final String dependencyResolution;
71
72
73
74
75
76
77
78
79 final String dependencyCollection;
80
81
82
83 final boolean directInvocationOnly;
84
85
86
87 final boolean projectRequired;
88
89
90
91 final boolean onlineRequired;
92
93
94
95
96 final boolean aggregator;
97
98
99
100 final boolean inheritedByDefault;
101
102
103
104 final String since;
105
106
107
108
109 final String deprecated;
110
111
112
113
114
115 final String configurator;
116
117
118
119 final List<Parameter> parameters;
120
121
122
123 final String id;
124
125
126
127 final String fullGoalName;
128
129
130
131
132
133 MojoDescriptor(
134 String goal,
135 String description,
136 String implementation,
137 String language,
138 String phase,
139 String executePhase,
140 String executeGoal,
141 String executeLifecycle,
142 String dependencyResolution,
143 String dependencyCollection,
144 boolean directInvocationOnly,
145 boolean projectRequired,
146 boolean onlineRequired,
147 boolean aggregator,
148 boolean inheritedByDefault,
149 String since,
150 String deprecated,
151 String configurator,
152 Collection<Parameter> parameters,
153 String id,
154 String fullGoalName
155 ) {
156 this.goal = goal;
157 this.description = description;
158 this.implementation = implementation;
159 this.language = language;
160 this.phase = phase;
161 this.executePhase = executePhase;
162 this.executeGoal = executeGoal;
163 this.executeLifecycle = executeLifecycle;
164 this.dependencyResolution = dependencyResolution;
165 this.dependencyCollection = dependencyCollection;
166 this.directInvocationOnly = directInvocationOnly;
167 this.projectRequired = projectRequired;
168 this.onlineRequired = onlineRequired;
169 this.aggregator = aggregator;
170 this.inheritedByDefault = inheritedByDefault;
171 this.since = since;
172 this.deprecated = deprecated;
173 this.configurator = configurator;
174 this.parameters = ImmutableCollections.copy(parameters);
175 this.id = id;
176 this.fullGoalName = fullGoalName;
177 }
178
179
180
181
182
183
184
185 public String getGoal() {
186 return this.goal;
187 }
188
189
190
191
192
193
194 public String getDescription() {
195 return this.description;
196 }
197
198
199
200
201
202
203 public String getImplementation() {
204 return this.implementation;
205 }
206
207
208
209
210
211
212 public String getLanguage() {
213 return this.language;
214 }
215
216
217
218
219
220
221
222
223
224 public String getPhase() {
225 return this.phase;
226 }
227
228
229
230
231
232
233 public String getExecutePhase() {
234 return this.executePhase;
235 }
236
237
238
239
240
241
242 public String getExecuteGoal() {
243 return this.executeGoal;
244 }
245
246
247
248
249
250
251 public String getExecuteLifecycle() {
252 return this.executeLifecycle;
253 }
254
255
256
257
258
259
260
261
262 public String getDependencyResolution() {
263 return this.dependencyResolution;
264 }
265
266
267
268
269
270
271
272
273
274
275
276 public String getDependencyCollection() {
277 return this.dependencyCollection;
278 }
279
280
281
282
283
284
285 public boolean isDirectInvocationOnly() {
286 return this.directInvocationOnly;
287 }
288
289
290
291
292
293
294 public boolean isProjectRequired() {
295 return this.projectRequired;
296 }
297
298
299
300
301
302
303 public boolean isOnlineRequired() {
304 return this.onlineRequired;
305 }
306
307
308
309
310
311
312
313 public boolean isAggregator() {
314 return this.aggregator;
315 }
316
317
318
319
320
321
322 public boolean isInheritedByDefault() {
323 return this.inheritedByDefault;
324 }
325
326
327
328
329
330
331 public String getSince() {
332 return this.since;
333 }
334
335
336
337
338
339
340
341 public String getDeprecated() {
342 return this.deprecated;
343 }
344
345
346
347
348
349
350
351
352 public String getConfigurator() {
353 return this.configurator;
354 }
355
356
357
358
359
360
361 @Nonnull
362 public List<Parameter> getParameters() {
363 return this.parameters;
364 }
365
366
367
368
369
370
371 public String getId() {
372 return this.id;
373 }
374
375
376
377
378
379
380 public String getFullGoalName() {
381 return this.fullGoalName;
382 }
383
384
385
386
387
388
389 @Nonnull
390 public Builder with() {
391 return newBuilder(this);
392 }
393
394
395
396
397
398
399 @Nonnull
400 public MojoDescriptor withGoal(String goal) {
401 return newBuilder(this, true).goal(goal).build();
402 }
403
404
405
406
407
408
409 @Nonnull
410 public MojoDescriptor withDescription(String description) {
411 return newBuilder(this, true).description(description).build();
412 }
413
414
415
416
417
418
419 @Nonnull
420 public MojoDescriptor withImplementation(String implementation) {
421 return newBuilder(this, true).implementation(implementation).build();
422 }
423
424
425
426
427
428
429 @Nonnull
430 public MojoDescriptor withLanguage(String language) {
431 return newBuilder(this, true).language(language).build();
432 }
433
434
435
436
437
438
439 @Nonnull
440 public MojoDescriptor withPhase(String phase) {
441 return newBuilder(this, true).phase(phase).build();
442 }
443
444
445
446
447
448
449 @Nonnull
450 public MojoDescriptor withExecutePhase(String executePhase) {
451 return newBuilder(this, true).executePhase(executePhase).build();
452 }
453
454
455
456
457
458
459 @Nonnull
460 public MojoDescriptor withExecuteGoal(String executeGoal) {
461 return newBuilder(this, true).executeGoal(executeGoal).build();
462 }
463
464
465
466
467
468
469 @Nonnull
470 public MojoDescriptor withExecuteLifecycle(String executeLifecycle) {
471 return newBuilder(this, true).executeLifecycle(executeLifecycle).build();
472 }
473
474
475
476
477
478
479 @Nonnull
480 public MojoDescriptor withDependencyResolution(String dependencyResolution) {
481 return newBuilder(this, true).dependencyResolution(dependencyResolution).build();
482 }
483
484
485
486
487
488
489 @Nonnull
490 public MojoDescriptor withDependencyCollection(String dependencyCollection) {
491 return newBuilder(this, true).dependencyCollection(dependencyCollection).build();
492 }
493
494
495
496
497
498
499 @Nonnull
500 public MojoDescriptor withDirectInvocationOnly(boolean directInvocationOnly) {
501 return newBuilder(this, true).directInvocationOnly(directInvocationOnly).build();
502 }
503
504
505
506
507
508
509 @Nonnull
510 public MojoDescriptor withProjectRequired(boolean projectRequired) {
511 return newBuilder(this, true).projectRequired(projectRequired).build();
512 }
513
514
515
516
517
518
519 @Nonnull
520 public MojoDescriptor withOnlineRequired(boolean onlineRequired) {
521 return newBuilder(this, true).onlineRequired(onlineRequired).build();
522 }
523
524
525
526
527
528
529 @Nonnull
530 public MojoDescriptor withAggregator(boolean aggregator) {
531 return newBuilder(this, true).aggregator(aggregator).build();
532 }
533
534
535
536
537
538
539 @Nonnull
540 public MojoDescriptor withInheritedByDefault(boolean inheritedByDefault) {
541 return newBuilder(this, true).inheritedByDefault(inheritedByDefault).build();
542 }
543
544
545
546
547
548
549 @Nonnull
550 public MojoDescriptor withSince(String since) {
551 return newBuilder(this, true).since(since).build();
552 }
553
554
555
556
557
558
559 @Nonnull
560 public MojoDescriptor withDeprecated(String deprecated) {
561 return newBuilder(this, true).deprecated(deprecated).build();
562 }
563
564
565
566
567
568
569 @Nonnull
570 public MojoDescriptor withConfigurator(String configurator) {
571 return newBuilder(this, true).configurator(configurator).build();
572 }
573
574
575
576
577
578
579 @Nonnull
580 public MojoDescriptor withParameters(Collection<Parameter> parameters) {
581 return newBuilder(this, true).parameters(parameters).build();
582 }
583
584
585
586
587
588
589 @Nonnull
590 public MojoDescriptor withId(String id) {
591 return newBuilder(this, true).id(id).build();
592 }
593
594
595
596
597
598
599 @Nonnull
600 public MojoDescriptor withFullGoalName(String fullGoalName) {
601 return newBuilder(this, true).fullGoalName(fullGoalName).build();
602 }
603
604
605
606
607
608
609
610
611 @Nonnull
612 public static MojoDescriptor newInstance() {
613 return newInstance(true);
614 }
615
616
617
618
619
620
621
622
623 @Nonnull
624 public static MojoDescriptor newInstance(boolean withDefaults) {
625 return newBuilder(withDefaults).build();
626 }
627
628
629
630
631
632
633
634
635 @Nonnull
636 public static Builder newBuilder() {
637 return newBuilder(true);
638 }
639
640
641
642
643
644
645
646 @Nonnull
647 public static Builder newBuilder(boolean withDefaults) {
648 return new Builder(withDefaults);
649 }
650
651
652
653
654
655
656
657
658 @Nonnull
659 public static Builder newBuilder(MojoDescriptor from) {
660 return newBuilder(from, false);
661 }
662
663
664
665
666
667
668
669
670 @Nonnull
671 public static Builder newBuilder(MojoDescriptor from, boolean forceCopy) {
672 return new Builder(from, forceCopy);
673 }
674
675
676
677
678
679
680 @NotThreadSafe
681 public static class Builder
682 {
683 MojoDescriptor base;
684 String goal;
685 String description;
686 String implementation;
687 String language;
688 String phase;
689 String executePhase;
690 String executeGoal;
691 String executeLifecycle;
692 String dependencyResolution;
693 String dependencyCollection;
694 Boolean directInvocationOnly;
695 Boolean projectRequired;
696 Boolean onlineRequired;
697 Boolean aggregator;
698 Boolean inheritedByDefault;
699 String since;
700 String deprecated;
701 String configurator;
702 Collection<Parameter> parameters;
703 String id;
704 String fullGoalName;
705
706 Builder(boolean withDefaults) {
707 if (withDefaults) {
708 this.language = "java";
709 this.dependencyResolution = "runtime";
710 this.directInvocationOnly = false;
711 this.projectRequired = true;
712 this.onlineRequired = false;
713 this.aggregator = false;
714 this.inheritedByDefault = true;
715 }
716 }
717
718 Builder(MojoDescriptor base, boolean forceCopy) {
719 if (forceCopy) {
720 this.goal = base.goal;
721 this.description = base.description;
722 this.implementation = base.implementation;
723 this.language = base.language;
724 this.phase = base.phase;
725 this.executePhase = base.executePhase;
726 this.executeGoal = base.executeGoal;
727 this.executeLifecycle = base.executeLifecycle;
728 this.dependencyResolution = base.dependencyResolution;
729 this.dependencyCollection = base.dependencyCollection;
730 this.directInvocationOnly = base.directInvocationOnly;
731 this.projectRequired = base.projectRequired;
732 this.onlineRequired = base.onlineRequired;
733 this.aggregator = base.aggregator;
734 this.inheritedByDefault = base.inheritedByDefault;
735 this.since = base.since;
736 this.deprecated = base.deprecated;
737 this.configurator = base.configurator;
738 this.parameters = base.parameters;
739 this.id = base.id;
740 this.fullGoalName = base.fullGoalName;
741 } else {
742 this.base = base;
743 }
744 }
745
746 @Nonnull
747 public Builder goal(String goal) {
748 this.goal = goal;
749 return this;
750 }
751
752 @Nonnull
753 public Builder description(String description) {
754 this.description = description;
755 return this;
756 }
757
758 @Nonnull
759 public Builder implementation(String implementation) {
760 this.implementation = implementation;
761 return this;
762 }
763
764 @Nonnull
765 public Builder language(String language) {
766 this.language = language;
767 return this;
768 }
769
770 @Nonnull
771 public Builder phase(String phase) {
772 this.phase = phase;
773 return this;
774 }
775
776 @Nonnull
777 public Builder executePhase(String executePhase) {
778 this.executePhase = executePhase;
779 return this;
780 }
781
782 @Nonnull
783 public Builder executeGoal(String executeGoal) {
784 this.executeGoal = executeGoal;
785 return this;
786 }
787
788 @Nonnull
789 public Builder executeLifecycle(String executeLifecycle) {
790 this.executeLifecycle = executeLifecycle;
791 return this;
792 }
793
794 @Nonnull
795 public Builder dependencyResolution(String dependencyResolution) {
796 this.dependencyResolution = dependencyResolution;
797 return this;
798 }
799
800 @Nonnull
801 public Builder dependencyCollection(String dependencyCollection) {
802 this.dependencyCollection = dependencyCollection;
803 return this;
804 }
805
806 @Nonnull
807 public Builder directInvocationOnly(boolean directInvocationOnly) {
808 this.directInvocationOnly = directInvocationOnly;
809 return this;
810 }
811
812 @Nonnull
813 public Builder projectRequired(boolean projectRequired) {
814 this.projectRequired = projectRequired;
815 return this;
816 }
817
818 @Nonnull
819 public Builder onlineRequired(boolean onlineRequired) {
820 this.onlineRequired = onlineRequired;
821 return this;
822 }
823
824 @Nonnull
825 public Builder aggregator(boolean aggregator) {
826 this.aggregator = aggregator;
827 return this;
828 }
829
830 @Nonnull
831 public Builder inheritedByDefault(boolean inheritedByDefault) {
832 this.inheritedByDefault = inheritedByDefault;
833 return this;
834 }
835
836 @Nonnull
837 public Builder since(String since) {
838 this.since = since;
839 return this;
840 }
841
842 @Nonnull
843 public Builder deprecated(String deprecated) {
844 this.deprecated = deprecated;
845 return this;
846 }
847
848 @Nonnull
849 public Builder configurator(String configurator) {
850 this.configurator = configurator;
851 return this;
852 }
853
854 @Nonnull
855 public Builder parameters(Collection<Parameter> parameters) {
856 this.parameters = parameters;
857 return this;
858 }
859
860 @Nonnull
861 public Builder id(String id) {
862 this.id = id;
863 return this;
864 }
865
866 @Nonnull
867 public Builder fullGoalName(String fullGoalName) {
868 this.fullGoalName = fullGoalName;
869 return this;
870 }
871
872
873 @Nonnull
874 public MojoDescriptor build() {
875 if (base != null
876 && (goal == null || goal == base.goal)
877 && (description == null || description == base.description)
878 && (implementation == null || implementation == base.implementation)
879 && (language == null || language == base.language)
880 && (phase == null || phase == base.phase)
881 && (executePhase == null || executePhase == base.executePhase)
882 && (executeGoal == null || executeGoal == base.executeGoal)
883 && (executeLifecycle == null || executeLifecycle == base.executeLifecycle)
884 && (dependencyResolution == null || dependencyResolution == base.dependencyResolution)
885 && (dependencyCollection == null || dependencyCollection == base.dependencyCollection)
886 && (directInvocationOnly == null || directInvocationOnly == base.directInvocationOnly)
887 && (projectRequired == null || projectRequired == base.projectRequired)
888 && (onlineRequired == null || onlineRequired == base.onlineRequired)
889 && (aggregator == null || aggregator == base.aggregator)
890 && (inheritedByDefault == null || inheritedByDefault == base.inheritedByDefault)
891 && (since == null || since == base.since)
892 && (deprecated == null || deprecated == base.deprecated)
893 && (configurator == null || configurator == base.configurator)
894 && (parameters == null || parameters == base.parameters)
895 && (id == null || id == base.id)
896 && (fullGoalName == null || fullGoalName == base.fullGoalName)
897 ) {
898 return base;
899 }
900 return new MojoDescriptor(
901 goal != null ? goal : (base != null ? base.goal : null),
902 description != null ? description : (base != null ? base.description : null),
903 implementation != null ? implementation : (base != null ? base.implementation : null),
904 language != null ? language : (base != null ? base.language : null),
905 phase != null ? phase : (base != null ? base.phase : null),
906 executePhase != null ? executePhase : (base != null ? base.executePhase : null),
907 executeGoal != null ? executeGoal : (base != null ? base.executeGoal : null),
908 executeLifecycle != null ? executeLifecycle : (base != null ? base.executeLifecycle : null),
909 dependencyResolution != null ? dependencyResolution : (base != null ? base.dependencyResolution : null),
910 dependencyCollection != null ? dependencyCollection : (base != null ? base.dependencyCollection : null),
911 directInvocationOnly != null ? directInvocationOnly : (base != null ? base.directInvocationOnly : false),
912 projectRequired != null ? projectRequired : (base != null ? base.projectRequired : true),
913 onlineRequired != null ? onlineRequired : (base != null ? base.onlineRequired : false),
914 aggregator != null ? aggregator : (base != null ? base.aggregator : false),
915 inheritedByDefault != null ? inheritedByDefault : (base != null ? base.inheritedByDefault : true),
916 since != null ? since : (base != null ? base.since : null),
917 deprecated != null ? deprecated : (base != null ? base.deprecated : null),
918 configurator != null ? configurator : (base != null ? base.configurator : null),
919 parameters != null ? parameters : (base != null ? base.parameters : null),
920 id != null ? id : (base != null ? base.id : null),
921 fullGoalName != null ? fullGoalName : (base != null ? base.fullGoalName : null)
922 );
923 }
924 }
925
926 }