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