1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.lifecycle.internal;
20
21 import javax.inject.Named;
22 import javax.inject.Singleton;
23
24 import org.apache.maven.execution.ExecutionEvent;
25 import org.apache.maven.execution.ExecutionListener;
26 import org.apache.maven.execution.MavenSession;
27 import org.apache.maven.plugin.MojoExecution;
28
29
30
31
32
33
34
35 @Named
36 @Singleton
37 public class DefaultExecutionEventCatapult implements ExecutionEventCatapult {
38
39 @Override
40 public void fire(ExecutionEvent.Type eventType, MavenSession session, MojoExecution mojoExecution) {
41 fire(eventType, session, mojoExecution, null);
42 }
43
44 @Override
45 public void fire(
46 ExecutionEvent.Type eventType, MavenSession session, MojoExecution mojoExecution, Exception exception) {
47 ExecutionListener listener = session.getRequest().getExecutionListener();
48
49 if (listener != null) {
50 ExecutionEvent event = new DefaultExecutionEvent(eventType, session, mojoExecution, exception);
51
52 switch (eventType) {
53 case ProjectDiscoveryStarted:
54 listener.projectDiscoveryStarted(event);
55 break;
56
57 case SessionStarted:
58 listener.sessionStarted(event);
59 break;
60 case SessionEnded:
61 listener.sessionEnded(event);
62 break;
63
64 case ProjectSkipped:
65 listener.projectSkipped(event);
66 break;
67 case ProjectStarted:
68 listener.projectStarted(event);
69 break;
70 case ProjectSucceeded:
71 listener.projectSucceeded(event);
72 break;
73 case ProjectFailed:
74 listener.projectFailed(event);
75 break;
76
77 case MojoSkipped:
78 listener.mojoSkipped(event);
79 break;
80 case MojoStarted:
81 listener.mojoStarted(event);
82 break;
83 case MojoSucceeded:
84 listener.mojoSucceeded(event);
85 break;
86 case MojoFailed:
87 listener.mojoFailed(event);
88 break;
89
90 case ForkStarted:
91 listener.forkStarted(event);
92 break;
93 case ForkSucceeded:
94 listener.forkSucceeded(event);
95 break;
96 case ForkFailed:
97 listener.forkFailed(event);
98 break;
99
100 case ForkedProjectStarted:
101 listener.forkedProjectStarted(event);
102 break;
103 case ForkedProjectSucceeded:
104 listener.forkedProjectSucceeded(event);
105 break;
106 case ForkedProjectFailed:
107 listener.forkedProjectFailed(event);
108 break;
109
110 default:
111 throw new IllegalStateException("Unknown execution event type " + eventType);
112 }
113 }
114 }
115 }