1 package org.apache.maven.lifecycle.internal;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.maven.execution.ExecutionEvent;
23 import org.apache.maven.execution.ExecutionListener;
24 import org.apache.maven.execution.MavenSession;
25 import org.apache.maven.plugin.MojoExecution;
26 import org.codehaus.plexus.component.annotations.Component;
27
28 /**
29 * Assists in firing execution events. <strong>Warning:</strong> This is an internal utility class that is only public
30 * for technical reasons, it is not part of the public API. In particular, this class can be changed or deleted without
31 * prior notice.
32 *
33 * @author Benjamin Bentmann
34 */
35 @Component( role = ExecutionEventCatapult.class )
36 public class DefaultExecutionEventCatapult
37 implements ExecutionEventCatapult
38 {
39
40 public void fire( ExecutionEvent.Type eventType, MavenSession session, MojoExecution mojoExecution )
41 {
42 fire( eventType, session, mojoExecution, null );
43 }
44
45 public void fire( ExecutionEvent.Type eventType, MavenSession session, MojoExecution mojoExecution,
46 Exception exception )
47 {
48 ExecutionListener listener = session.getRequest().getExecutionListener();
49
50 if ( listener != null )
51 {
52 ExecutionEvent event = new DefaultExecutionEvent( eventType, session, mojoExecution, exception );
53
54 switch ( eventType )
55 {
56 case ProjectDiscoveryStarted:
57 listener.projectDiscoveryStarted( event );
58 break;
59
60 case SessionStarted:
61 listener.sessionStarted( event );
62 break;
63 case SessionEnded:
64 listener.sessionEnded( event );
65 break;
66
67 case ProjectSkipped:
68 listener.projectSkipped( event );
69 break;
70 case ProjectStarted:
71 listener.projectStarted( event );
72 break;
73 case ProjectSucceeded:
74 listener.projectSucceeded( event );
75 break;
76 case ProjectFailed:
77 listener.projectFailed( event );
78 break;
79
80 case MojoSkipped:
81 listener.mojoSkipped( event );
82 break;
83 case MojoStarted:
84 listener.mojoStarted( event );
85 break;
86 case MojoSucceeded:
87 listener.mojoSucceeded( event );
88 break;
89 case MojoFailed:
90 listener.mojoFailed( event );
91 break;
92
93 case ForkStarted:
94 listener.forkStarted( event );
95 break;
96 case ForkSucceeded:
97 listener.forkSucceeded( event );
98 break;
99 case ForkFailed:
100 listener.forkFailed( event );
101 break;
102
103 case ForkedProjectStarted:
104 listener.forkedProjectStarted( event );
105 break;
106 case ForkedProjectSucceeded:
107 listener.forkedProjectSucceeded( event );
108 break;
109 case ForkedProjectFailed:
110 listener.forkedProjectFailed( event );
111 break;
112
113 default:
114 throw new IllegalStateException( "Unknown execution event type " + eventType );
115 }
116 }
117 }
118
119 }