org.gradle.tooling
Interface ProjectConnection


public interface ProjectConnection

Represents a long-lived connection to a Gradle project.

Thread safety

All implementations of GradleConnection are thread-safe, and may be shared by any number of threads.

All notifications from a given GradleConnection instance are delivered by a single thread at a time. Note, however, that the delivery thread may change over time.


Method Summary
 void close()
          Closes this connection.
<T extends Project>
T
getModel(Class<T> viewType)
          Fetches a snapshot of the model for this project.
<T extends Project>
void
getModel(Class<T> viewType, ResultHandler<? super T> handler)
          Fetches a snapshot of the model for this project asynchronously.
 

Method Detail

getModel

<T extends Project> T getModel(Class<T> viewType)
                           throws GradleConnectionException
Fetches a snapshot of the model for this project. This method blocks until the model is available.

Type Parameters:
T - The model type.
Parameters:
viewType - The model type.
Returns:
The model.
Throws:
UnsupportedVersionException - When the target Gradle version does not support the given model.
GradleConnectionException - On some failure to communicate with Gradle.
IllegalStateException - When this connection has been closed or is closing.

getModel

<T extends Project> void getModel(Class<T> viewType,
                                  ResultHandler<? super T> handler)
              throws IllegalStateException
Fetches a snapshot of the model for this project asynchronously. This method return immediately, and the result of the operation is passed to the supplied result handler.

Type Parameters:
T - The model type.
Parameters:
viewType - The model type.
handler - The handler to pass the result to.
Throws:
IllegalStateException - When this connection has been closed or is closing.

close

void close()
Closes this connection. Blocks until the close is complete. Once this method has returned, no more notifications will be delivered by any threads.