1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.shared.release.config;
20
21 import java.util.List;
22 import java.util.regex.Matcher;
23 import java.util.regex.Pattern;
24
25 import org.apache.maven.model.Scm;
26 import org.apache.maven.shared.release.util.ReleaseUtil;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30
31
32
33
34
35
36 public class ReleaseDescriptorBuilder {
37 private static final Pattern PROPERTY_PATTERN = Pattern.compile("\\$\\{[^}]+}");
38
39 private final Logger logger;
40
41
42
43
44
45
46 public static final class BuilderReleaseDescriptor extends ModelloReleaseDescriptor implements ReleaseDescriptor {
47 private BuilderReleaseDescriptor() {}
48 }
49
50 private final BuilderReleaseDescriptor releaseDescriptor;
51
52
53
54
55 public ReleaseDescriptorBuilder() {
56 this(LoggerFactory.getLogger(ReleaseDescriptorBuilder.class));
57 }
58
59
60
61
62 ReleaseDescriptorBuilder(Logger logger) {
63 this.releaseDescriptor = new BuilderReleaseDescriptor();
64 this.releaseDescriptor.setLineSeparator(ReleaseUtil.LS);
65 this.logger = logger;
66 }
67
68
69
70
71
72
73
74 public ReleaseDescriptorBuilder addCheckModificationExclude(String string) {
75 releaseDescriptor.addCheckModificationExclude(string);
76 return this;
77 }
78
79
80
81
82
83
84
85 public ReleaseDescriptorBuilder setActivateProfiles(List<String> profiles) {
86 releaseDescriptor.setActivateProfiles(profiles);
87 return this;
88 }
89
90
91
92
93
94
95
96 public ReleaseDescriptorBuilder setAddSchema(boolean addSchema) {
97 releaseDescriptor.setAddSchema(addSchema);
98 return this;
99 }
100
101
102
103
104
105
106
107 public ReleaseDescriptorBuilder setAdditionalArguments(String additionalArguments) {
108 if (additionalArguments != null) {
109 Matcher matcher = PROPERTY_PATTERN.matcher(additionalArguments);
110 StringBuffer buf = new StringBuffer();
111 while (matcher.find()) {
112 matcher.appendReplacement(buf, "");
113 logger.warn("arguments parameter contains unresolved property: '{}'", matcher.group());
114 }
115 matcher.appendTail(buf);
116
117 releaseDescriptor.setAdditionalArguments(buf.toString());
118 } else {
119 releaseDescriptor.setAdditionalArguments(null);
120 }
121 return this;
122 }
123
124
125
126
127
128
129
130 public ReleaseDescriptorBuilder setAllowTimestampedSnapshots(boolean allowTimestampedSnapshots) {
131 releaseDescriptor.setAllowTimestampedSnapshots(allowTimestampedSnapshots);
132 return this;
133 }
134
135
136
137
138
139
140
141 public ReleaseDescriptorBuilder setAutoVersionSubmodules(boolean autoVersionSubmodules) {
142 releaseDescriptor.setAutoVersionSubmodules(autoVersionSubmodules);
143 return this;
144 }
145
146
147
148
149
150
151
152 public ReleaseDescriptorBuilder setBranchCreation(boolean branchCreation) {
153 releaseDescriptor.setBranchCreation(branchCreation);
154 return this;
155 }
156
157
158
159
160
161
162
163 public ReleaseDescriptorBuilder setCheckModificationExcludes(List<String> checkModificationExcludes) {
164 releaseDescriptor.setCheckModificationExcludes(checkModificationExcludes);
165 return this;
166 }
167
168
169
170
171
172
173
174 public ReleaseDescriptorBuilder setCheckoutDirectory(String checkoutDirectory) {
175 releaseDescriptor.setCheckoutDirectory(checkoutDirectory);
176 return this;
177 }
178
179
180
181
182
183
184
185 public ReleaseDescriptorBuilder setCommitByProject(boolean commitByProject) {
186 releaseDescriptor.setCommitByProject(commitByProject);
187 return this;
188 }
189
190
191
192
193
194
195
196 public ReleaseDescriptorBuilder setCompletedPhase(String completedPhase) {
197 releaseDescriptor.setCompletedPhase(completedPhase);
198 return this;
199 }
200
201
202
203
204
205
206
207 public ReleaseDescriptorBuilder setCompletionGoals(String completionGoals) {
208 releaseDescriptor.setCompletionGoals(completionGoals);
209 return this;
210 }
211
212
213
214
215
216
217
218 public ReleaseDescriptorBuilder setDefaultDevelopmentVersion(String defaultDevelopmentVersion) {
219 releaseDescriptor.setDefaultDevelopmentVersion(defaultDevelopmentVersion);
220 return this;
221 }
222
223
224
225
226
227
228
229 public ReleaseDescriptorBuilder setDefaultReleaseVersion(String defaultReleaseVersion) {
230 releaseDescriptor.setDefaultReleaseVersion(defaultReleaseVersion);
231 return this;
232 }
233
234
235
236
237
238
239
240 public ReleaseDescriptorBuilder setDescription(String description) {
241 releaseDescriptor.setDescription(description);
242 return this;
243 }
244
245
246
247
248
249
250
251 public ReleaseDescriptorBuilder setGenerateReleasePoms(boolean generateReleasePoms) {
252 releaseDescriptor.setGenerateReleasePoms(generateReleasePoms);
253 return this;
254 }
255
256
257
258
259
260
261
262 public ReleaseDescriptorBuilder setInteractive(boolean interactive) {
263 releaseDescriptor.setInteractive(interactive);
264 return this;
265 }
266
267
268
269
270
271
272
273 public ReleaseDescriptorBuilder setLineSeparator(String ls) {
274 releaseDescriptor.setLineSeparator(ls);
275 return this;
276 }
277
278
279
280
281
282
283
284 public ReleaseDescriptorBuilder setLocalCheckout(boolean localCheckout) {
285 releaseDescriptor.setLocalCheckout(localCheckout);
286 return this;
287 }
288
289
290
291
292
293
294
295 public ReleaseDescriptorBuilder setModelEncoding(String modelEncoding) {
296 releaseDescriptor.setModelEncoding(modelEncoding);
297 return this;
298 }
299
300
301
302
303
304
305
306 public ReleaseDescriptorBuilder setName(String name) {
307 releaseDescriptor.setName(name);
308 return this;
309 }
310
311
312
313
314
315
316
317 public ReleaseDescriptorBuilder setPerformGoals(String performGoals) {
318 releaseDescriptor.setPerformGoals(performGoals);
319 return this;
320 }
321
322
323
324
325
326
327
328 public ReleaseDescriptorBuilder setPomFileName(String pomFileName) {
329 releaseDescriptor.setPomFileName(pomFileName);
330 return this;
331 }
332
333
334
335
336
337
338
339 public ReleaseDescriptorBuilder setPreparationGoals(String preparationGoals) {
340 releaseDescriptor.setPreparationGoals(preparationGoals);
341 return this;
342 }
343
344
345
346
347
348
349
350 public ReleaseDescriptorBuilder setProjectNamingPolicyId(String projectNamingPolicyId) {
351 releaseDescriptor.setProjectNamingPolicyId(projectNamingPolicyId);
352 return this;
353 }
354
355
356
357
358
359
360
361 public ReleaseDescriptorBuilder setProjectVersionPolicyId(String projectVersionPolicyId) {
362 releaseDescriptor.setProjectVersionPolicyId(projectVersionPolicyId);
363 return this;
364 }
365
366
367
368
369
370
371
372 public ReleaseDescriptorBuilder setProjectVersionPolicyConfig(String setProjectVersionPolicyConfig) {
373 releaseDescriptor.setProjectVersionPolicyConfig(setProjectVersionPolicyConfig);
374 return this;
375 }
376
377
378
379
380
381
382
383 public ReleaseDescriptorBuilder setPushChanges(boolean pushChanges) {
384 releaseDescriptor.setPushChanges(pushChanges);
385 return this;
386 }
387
388
389
390
391
392
393
394 public ReleaseDescriptorBuilder setWorkItem(String workItem) {
395 releaseDescriptor.setWorkItem(workItem);
396 return this;
397 }
398
399
400
401
402
403
404
405 public ReleaseDescriptorBuilder setReleaseStrategyId(String releaseStrategyId) {
406 releaseDescriptor.setReleaseStrategyId(releaseStrategyId);
407 return this;
408 }
409
410
411
412
413
414
415
416 public ReleaseDescriptorBuilder setRemoteTagging(boolean remoteTagging) {
417 releaseDescriptor.setRemoteTagging(remoteTagging);
418 return this;
419 }
420
421
422
423
424
425
426
427 public ReleaseDescriptorBuilder setScmBranchBase(String scmBranchBase) {
428 releaseDescriptor.setScmBranchBase(scmBranchBase);
429 return this;
430 }
431
432
433
434
435
436
437
438 public ReleaseDescriptorBuilder setScmCommentPrefix(String scmCommentPrefix) {
439 releaseDescriptor.setScmCommentPrefix(scmCommentPrefix);
440 return this;
441 }
442
443
444
445
446
447
448
449
450 public ReleaseDescriptorBuilder setScmShallowClone(boolean scmShallowClone) {
451 releaseDescriptor.setScmShallowClone(scmShallowClone);
452 return this;
453 }
454
455
456
457
458
459
460
461
462 public ReleaseDescriptorBuilder setScmReleaseCommitComment(String scmReleaseCommitComment) {
463 releaseDescriptor.setScmReleaseCommitComment(scmReleaseCommitComment);
464 return this;
465 }
466
467
468
469
470
471
472
473
474 public ReleaseDescriptorBuilder setScmDevelopmentCommitComment(String scmDevelopmentCommitComment) {
475 releaseDescriptor.setScmDevelopmentCommitComment(scmDevelopmentCommitComment);
476 return this;
477 }
478
479
480
481
482
483
484
485
486 public ReleaseDescriptorBuilder setScmBranchCommitComment(String scmBranchCommitComment) {
487 releaseDescriptor.setScmBranchCommitComment(scmBranchCommitComment);
488 return this;
489 }
490
491
492
493
494
495
496
497
498 public ReleaseDescriptorBuilder setScmRollbackCommitComment(String scmRollbackCommitComment) {
499 releaseDescriptor.setScmRollbackCommitComment(scmRollbackCommitComment);
500 return this;
501 }
502
503
504
505
506
507
508
509 public ReleaseDescriptorBuilder setScmId(String scmId) {
510 releaseDescriptor.setScmId(scmId);
511 return this;
512 }
513
514
515
516
517
518
519
520 public ReleaseDescriptorBuilder setScmPassword(String scmPassword) {
521 releaseDescriptor.setScmPassword(scmPassword);
522 return this;
523 }
524
525
526
527
528
529
530
531 public ReleaseDescriptorBuilder setScmPrivateKey(String scmPrivateKey) {
532 releaseDescriptor.setScmPrivateKey(scmPrivateKey);
533 return this;
534 }
535
536
537
538
539
540
541
542 public ReleaseDescriptorBuilder setScmPrivateKeyPassPhrase(String scmPrivateKeyPassPhrase) {
543 releaseDescriptor.setScmPrivateKeyPassPhrase(scmPrivateKeyPassPhrase);
544 return this;
545 }
546
547
548
549
550
551
552
553 public ReleaseDescriptorBuilder setScmRelativePathProjectDirectory(String scmRelativePathProjectDirectory) {
554 releaseDescriptor.setScmRelativePathProjectDirectory(scmRelativePathProjectDirectory);
555 return this;
556 }
557
558
559
560
561
562
563
564 public ReleaseDescriptorBuilder setScmReleaseLabel(String scmReleaseLabel) {
565 releaseDescriptor.setScmReleaseLabel(scmReleaseLabel);
566 return this;
567 }
568
569
570
571
572
573
574
575 public ReleaseDescriptorBuilder setScmReleasedPomRevision(String scmReleasedPomRevision) {
576 releaseDescriptor.setScmReleasedPomRevision(scmReleasedPomRevision);
577 return this;
578 }
579
580
581
582
583
584
585
586 public ReleaseDescriptorBuilder setScmSourceUrl(String scmSourceUrl) {
587 releaseDescriptor.setScmSourceUrl(scmSourceUrl);
588 return this;
589 }
590
591
592
593
594
595
596
597 public ReleaseDescriptorBuilder setScmTagBase(String scmTagBase) {
598 releaseDescriptor.setScmTagBase(scmTagBase);
599 return this;
600 }
601
602
603
604
605
606
607
608 public ReleaseDescriptorBuilder setScmTagNameFormat(String scmTagNameFormat) {
609 releaseDescriptor.setScmTagNameFormat(scmTagNameFormat);
610 return this;
611 }
612
613
614
615
616
617
618
619 public ReleaseDescriptorBuilder setScmSignTags(boolean signTags) {
620 releaseDescriptor.setScmSignTags(signTags);
621 return this;
622 }
623
624
625
626
627
628
629
630 public ReleaseDescriptorBuilder setScmUseEditMode(boolean scmUseEditMode) {
631 releaseDescriptor.setScmUseEditMode(scmUseEditMode);
632 return this;
633 }
634
635
636
637
638
639
640
641 public ReleaseDescriptorBuilder setScmUsername(String scmUsername) {
642 releaseDescriptor.setScmUsername(scmUsername);
643 return this;
644 }
645
646
647
648
649
650
651
652 public ReleaseDescriptorBuilder setSnapshotReleasePluginAllowed(boolean snapshotReleasePluginAllowed) {
653 releaseDescriptor.setSnapshotReleasePluginAllowed(snapshotReleasePluginAllowed);
654 return this;
655 }
656
657
658
659
660
661
662
663 public ReleaseDescriptorBuilder setSuppressCommitBeforeTagOrBranch(boolean suppressCommitBeforeTagOrBranch) {
664 releaseDescriptor.setSuppressCommitBeforeTagOrBranch(suppressCommitBeforeTagOrBranch);
665 return this;
666 }
667
668
669
670
671
672
673
674 public ReleaseDescriptorBuilder setUpdateBranchVersions(boolean updateBranchVersions) {
675 releaseDescriptor.setUpdateBranchVersions(updateBranchVersions);
676 return this;
677 }
678
679
680
681
682
683
684
685 public ReleaseDescriptorBuilder setUpdateDependencies(boolean updateDependencies) {
686 releaseDescriptor.setUpdateDependencies(updateDependencies);
687 return this;
688 }
689
690
691
692
693
694
695
696 public ReleaseDescriptorBuilder setUpdateVersionsToSnapshot(boolean updateVersionsToSnapshot) {
697 releaseDescriptor.setUpdateVersionsToSnapshot(updateVersionsToSnapshot);
698 return this;
699 }
700
701
702
703
704
705
706
707 public ReleaseDescriptorBuilder setUpdateWorkingCopyVersions(boolean updateWorkingCopyVersions) {
708 releaseDescriptor.setUpdateWorkingCopyVersions(updateWorkingCopyVersions);
709 return this;
710 }
711
712
713
714
715
716
717
718 public ReleaseDescriptorBuilder setUseReleaseProfile(boolean useReleaseProfile) {
719 releaseDescriptor.setUseReleaseProfile(useReleaseProfile);
720 return this;
721 }
722
723
724
725
726
727
728
729 public ReleaseDescriptorBuilder setWaitBeforeTagging(int waitBeforeTagging) {
730 releaseDescriptor.setWaitBeforeTagging(waitBeforeTagging);
731 return this;
732 }
733
734
735
736
737
738
739
740 public ReleaseDescriptorBuilder setWorkingDirectory(String workingDirectory) {
741 releaseDescriptor.setWorkingDirectory(workingDirectory);
742 return this;
743 }
744
745
746
747
748
749
750
751
752 public ReleaseDescriptorBuilder addReleaseVersion(String key, String value) {
753 releaseDescriptor.addReleaseVersion(key, value);
754 return this;
755 }
756
757
758
759
760
761
762
763
764 public ReleaseDescriptorBuilder addDevelopmentVersion(String key, String value) {
765 releaseDescriptor.addDevelopmentVersion(key, value);
766 return this;
767 }
768
769
770
771
772
773
774
775
776 public ReleaseDescriptorBuilder addOriginalScmInfo(String key, Scm value) {
777 releaseDescriptor.addOriginalScmInfo(key, value);
778 return this;
779 }
780
781
782
783
784
785
786
787 public void putOriginalVersion(String projectKey, String version) {
788 releaseDescriptor.addOriginalVersion(projectKey, version);
789 }
790
791
792
793
794
795
796
797
798 public ReleaseDescriptorBuilder addDependencyOriginalVersion(String dependencyKey, String version) {
799 releaseDescriptor.addDependencyOriginalVersion(dependencyKey, version);
800 return this;
801 }
802
803
804
805
806
807
808
809
810 public ReleaseDescriptorBuilder addDependencyReleaseVersion(String dependencyKey, String version) {
811 releaseDescriptor.addDependencyReleaseVersion(dependencyKey, version);
812 return this;
813 }
814
815
816
817
818
819
820
821
822 public ReleaseDescriptorBuilder addDependencyDevelopmentVersion(String dependencyKey, String version) {
823 releaseDescriptor.addDependencyDevelopmentVersion(dependencyKey, version);
824 return this;
825 }
826
827
828
829
830
831
832
833 public ReleaseDescriptorBuilder setAutoResolveSnapshots(String autoResolveSnapshots) {
834 releaseDescriptor.setAutoResolveSnapshots(autoResolveSnapshots);
835 return this;
836 }
837
838
839
840
841
842
843
844 public ReleaseDescriptorBuilder setPinExternals(boolean pinExternals) {
845 releaseDescriptor.setPinExternals(pinExternals);
846 return this;
847 }
848
849 public BuilderReleaseDescriptor build() {
850 return releaseDescriptor;
851 }
852 }