View Javadoc

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          ExecutionListener listener = session.getRequest().getExecutionListener();
43  
44          if ( listener != null )
45          {
46              ExecutionEvent event = new DefaultExecutionEvent( eventType, session, mojoExecution );
47  
48              switch ( eventType )
49              {
50                  case ProjectDiscoveryStarted:
51                      listener.projectDiscoveryStarted( event );
52                      break;
53  
54                  case SessionStarted:
55                      listener.sessionStarted( event );
56                      break;
57                  case SessionEnded:
58                      listener.sessionEnded( event );
59                      break;
60  
61                  case ProjectSkipped:
62                      listener.projectSkipped( event );
63                      break;
64                  case ProjectStarted:
65                      listener.projectStarted( event );
66                      break;
67                  case ProjectSucceeded:
68                      listener.projectSucceeded( event );
69                      break;
70                  case ProjectFailed:
71                      listener.projectFailed( event );
72                      break;
73  
74                  case MojoSkipped:
75                      listener.mojoSkipped( event );
76                      break;
77                  case MojoStarted:
78                      listener.mojoStarted( event );
79                      break;
80                  case MojoSucceeded:
81                      listener.mojoSucceeded( event );
82                      break;
83                  case MojoFailed:
84                      listener.mojoFailed( event );
85                      break;
86  
87                  case ForkStarted:
88                      listener.forkStarted( event );
89                      break;
90                  case ForkSucceeded:
91                      listener.forkSucceeded( event );
92                      break;
93                  case ForkFailed:
94                      listener.forkFailed( event );
95                      break;
96  
97                  case ForkedProjectStarted:
98                      listener.forkedProjectStarted( event );
99                      break;
100                 case ForkedProjectSucceeded:
101                     listener.forkedProjectSucceeded( event );
102                     break;
103                 case ForkedProjectFailed:
104                     listener.forkedProjectFailed( event );
105                     break;
106 
107                 default:
108                     throw new IllegalStateException( "Unknown execution event type " + eventType );
109             }
110         }
111     }
112 
113 }