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