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