View Javadoc
1   package org.apache.maven.demo.extension;
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 javax.inject.Named;
23  import javax.inject.Singleton;
24  
25  import org.apache.maven.execution.AbstractExecutionListener;
26  import org.apache.maven.execution.ExecutionEvent;
27  
28  /**
29   * Execution Listener demo.
30   * <b>Question:</b> how to inject it to Maven runtime? LifecycleParticipant can get original ExecutionListener from
31   * request and replace with this class that should delegate to original listener (set <a href=
32   * "https://maven.apache.org/ref/3.6.3/maven-embedder/xref/org/apache/maven/cli/MavenCli.html#L1446">by CLI</a> to
33   * <a href=
34   * "https://maven.apache.org/ref/current/maven-embedder/apidocs/org/apache/maven/cli/event/ExecutionEventLogger.html"
35   * >ExecutionEventLogger</a> that displays to console).
36   * @see org.apache.maven.execution.MavenExecutionRequest#setExecutionListener(org.apache.maven.execution.ExecutionListener)
37   */
38  @Named( "demo" )
39  @Singleton
40  public class ExecutionListenerDemo
41      extends AbstractExecutionListener
42  {
43      public void projectDiscoveryStarted( ExecutionEvent event )
44      {
45          System.err.println( "ExecutionListenerDemo projectDiscoveryStarted" );
46      }
47  
48      public void sessionStarted( ExecutionEvent event )
49      {
50          System.err.println( "ExecutionListenerDemo sessionStarted" );
51      }
52  
53      public void sessionEnded( ExecutionEvent event )
54      {
55          System.err.println( "ExecutionListenerDemo sessionEnded" );
56      }
57  
58      public void projectSkipped( ExecutionEvent event )
59      {
60          System.err.println( "ExecutionListenerDemo projectSkipped" );
61      }
62  
63      public void projectStarted( ExecutionEvent event )
64      {
65          System.err.println( "ExecutionListenerDemo projectStarted" );
66      }
67  
68      public void projectSucceeded( ExecutionEvent event )
69      {
70          System.err.println( "ExecutionListenerDemo projectSucceeded" );
71      }
72  
73      public void projectFailed( ExecutionEvent event )
74      {
75          System.err.println( "ExecutionListenerDemo projectFailed" );
76      }
77  
78      public void forkStarted( ExecutionEvent event )
79      {
80          System.err.println( "ExecutionListenerDemo forkStarted" );
81      }
82  
83      public void forkSucceeded( ExecutionEvent event )
84      {
85          System.err.println( "ExecutionListenerDemo forkSucceeded" );
86      }
87  
88      public void forkFailed( ExecutionEvent event )
89      {
90          System.err.println( "ExecutionListenerDemo forkFailed" );
91      }
92  
93      public void mojoSkipped( ExecutionEvent event )
94      {
95          System.err.println( "ExecutionListenerDemo mojoSkipped" );
96      }
97  
98      public void mojoStarted( ExecutionEvent event )
99      {
100         System.err.println( "ExecutionListenerDemo mojoStarted" );
101     }
102 
103     public void mojoSucceeded( ExecutionEvent event )
104     {
105         System.err.println( "ExecutionListenerDemo mojoSucceeded" );
106     }
107 
108     public void mojoFailed( ExecutionEvent event )
109     {
110         System.err.println( "ExecutionListenerDemo mojoFailed" );
111     }
112 
113     public void forkedProjectStarted( ExecutionEvent event )
114     {
115         System.err.println( "ExecutionListenerDemo forkedProjectStarted" );
116     }
117 
118     public void forkedProjectSucceeded( ExecutionEvent event )
119     {
120         System.err.println( "ExecutionListenerDemo forkedProjectSucceeded" );
121     }
122 
123     public void forkedProjectFailed( ExecutionEvent event )
124     {
125         System.err.println( "ExecutionListenerDemo forkedProjectFailed" );
126     }
127 }