1 package org.apache.maven.api;
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.api.annotations.Experimental;
23 import org.apache.maven.api.annotations.Nonnull;
24
25 import java.util.Optional;
26
27 /**
28 * Event sent by maven during various phases of the build process.
29 * Such events can be listened to using {@link Listener}s objects
30 * registered in the {@link Session}.
31 *
32 * @since 4.0
33 */
34 @Experimental
35 public interface Event
36 {
37
38 /**
39 * Gets the type of the event.
40 *
41 * @return The type of the event, never {@code null}.
42 */
43 @Nonnull
44 EventType getType();
45
46 /**
47 * Gets the session from which this event originates.
48 *
49 * @return The current session, never {@code null}.
50 */
51 @Nonnull
52 Session getSession();
53
54 /**
55 * Gets the current project (if any).
56 *
57 * @return The current project or {@code empty()} if not applicable.
58 */
59 @Nonnull
60 Optional<Project> getProject();
61
62 /**
63 * Gets the current mojo execution (if any).
64 *
65 * @return The current mojo execution or {@code empty()} if not applicable.
66 */
67 @Nonnull
68 Optional<MojoExecution> getMojoExecution();
69
70 /**
71 * Gets the exception that caused the event (if any).
72 *
73 * @return The exception or {@code empty()} if none.
74 */
75 Optional<Exception> getException();
76
77 }