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;
20
21 import java.util.List;
22
23 import org.apache.maven.plugin.logging.Log;
24
25 import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
26
27
28
29
30
31
32 public class DefaultReleaseManagerListener implements ReleaseManagerListener {
33 private final Log log;
34
35 private final boolean dryRun;
36
37 private String goal;
38
39 private List<String> phases;
40
41 private int currentPhase;
42
43
44
45
46
47
48 public DefaultReleaseManagerListener(Log log) {
49 this(log, false);
50 }
51
52
53
54
55
56
57
58 public DefaultReleaseManagerListener(Log log, boolean dryRun) {
59 this.log = log;
60 this.dryRun = dryRun;
61 }
62
63 private void nextPhase(String name) {
64 currentPhase++;
65 if (!name.equals(phases.get(currentPhase))) {
66 log.warn("inconsistent phase name: expected '" + phases.get(currentPhase) + "' but got '" + name + "'");
67 }
68 }
69
70 public void goalStart(String goal, List<String> phases) {
71 log.info("starting " + buffer().mojo(goal) + " goal" + (dryRun ? " in dry-run mode" : "") + ", composed of "
72 + phases.size() + " phases: " + String.join(", ", phases));
73 currentPhase = -1;
74 this.phases = phases;
75 this.goal = goal;
76 }
77
78 public void phaseStart(String name) {
79 nextPhase(name);
80 log.info((currentPhase + 1) + "/" + phases.size() + ' ' + buffer().mojo(goal + ':' + name)
81 + (dryRun ? " dry-run" : ""));
82 }
83
84
85
86
87 public void phaseEnd() {
88
89 }
90
91 public void phaseSkip(String name) {
92 nextPhase(name);
93 }
94
95
96
97
98 public void goalEnd() {
99 goal = null;
100 phases = null;
101 }
102
103 public void error(String reason) {
104 log.error("error during phase " + (currentPhase + 1) + "/" + phases.size() + " " + phases.get(currentPhase)
105 + ": " + reason);
106 }
107 }