View Javadoc
1   /*
2   Copyright (c) 2025 Christoph Läubrich All rights reserved.
3   
4   This program is licensed to you under the Apache License Version 2.0,
5   and you may not use this file except in compliance with the Apache License Version 2.0.
6   You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7   
8   Unless required by applicable law or agreed to in writing,
9   software distributed under the Apache License Version 2.0 is distributed on an
10  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12  */
13  package org.codehaus.plexus.build.connect;
14  
15  import org.apache.maven.execution.MavenSession;
16  import org.codehaus.plexus.build.connect.messages.Message;
17  
18  /**
19   * A {@link BuildConnection} allow communication between a an IDE and a maven
20   * build to observe the state of the build and act on certain events. This is
21   * usually not used directly by mojos but invoked internally by other APIs.
22   */
23  public interface BuildConnection {
24  
25      /**
26       * Send a message and returns the reply from the other endpoint, should only be
27       * called from a maven thread!
28       *
29       * @param message      the message to send
30       * @param mavenSession the maven session to reference
31       * @return the reply message or <code>null</code> if this connection is not
32       *         enabled and the message was discarded.
33       */
34      Message send(Message message, MavenSession mavenSession);
35  
36      /**
37       * This method allows code to perform an eager check if a buildconnection is
38       * present to send messages. This can be used to guard operations to prevent
39       * allocate resources or objects if the message will be dropped.
40       *
41       * @return <code>true</code> if the connection can be used to send messages or
42       *         if they will be discarded
43       */
44      boolean isEnabled();
45  }