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