1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven;
20
21 import org.apache.maven.execution.MavenSession;
22
23 /**
24 * Allows core extensions to participate in Maven build session lifecycle.
25 *
26 * All callback methods (will) follow beforeXXX/afterXXX naming pattern to
27 * indicate at what lifecycle point it is being called.
28 *
29 * @see <a href="https://maven.apache.org/examples/maven-3-lifecycle-extensions.html">example</a>
30 * @see <a href="https://issues.apache.org/jira/browse/MNG-4224">MNG-4224</a>
31 * @since 3.0-alpha-3
32 */
33 public abstract class AbstractMavenLifecycleParticipant {
34
35 /**
36 * Invoked after all MavenProject instances have been created.
37 *
38 * This callback is intended to allow extensions to manipulate MavenProjects
39 * before they are sorted and actual build execution starts.
40 *
41 * @param session the Maven session
42 * @throws MavenExecutionException in case of issue
43 */
44 public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
45 // do nothing
46 }
47
48 /**
49 * Invoked after MavenSession instance has been created.
50 *
51 * This callback is intended to allow extensions to inject execution properties,
52 * activate profiles and perform similar tasks that affect MavenProject
53 * instance construction.
54 *
55 * @param session the Maven session
56 * @throws MavenExecutionException in case of issue
57 */
58 // TODO This is too early for build extensions, so maybe just remove it?
59 public void afterSessionStart(MavenSession session) throws MavenExecutionException {
60 // do nothing
61 }
62
63 /**
64 * Invoked after all projects were built.
65 *
66 * This callback is intended to allow extensions to perform cleanup of any
67 * allocated external resources after the build. It is invoked on best-effort
68 * basis and may be missed due to an Error or RuntimeException in Maven core
69 * code.
70 *
71 * @param session the Maven session
72 * @throws MavenExecutionException in case of issue
73 * @since 3.2.1, MNG-5389
74 */
75 public void afterSessionEnd(MavenSession session) throws MavenExecutionException {
76 // do nothing
77 }
78 }