public interface ProjectConnection
ProjectConnection by using GradleConnector.connect().
ProjectConnection connection = GradleConnector.newConnector()
.forProjectDirectory(new File("someFolder"))
.connect();
try {
//obtain some information from the build
BuildEnvironment environment = connection.model(BuildEnvironment.class)
.get();
//run some tasks
connection.newBuild()
.forTasks("tasks")
.setStandardOutput(System.out)
.run();
} finally {
connection.close();
}
All implementations of ProjectConnection are thread-safe, and may be shared by any number of threads.
All notifications from a given ProjectConnection instance are delivered by a single thread at a time. Note, however, that the delivery thread may change over time.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this connection.
|
<T extends Model> |
getModel(Class<T> viewType)
Fetches a snapshot of the model of the given type for this project.
|
<T extends Model> |
getModel(Class<T> viewType,
ResultHandler<? super T> handler)
Fetches a snapshot of the model for this project asynchronously.
|
<T extends Model> |
model(Class<T> modelType)
Creates a builder which can be used to build the model of the given type.
|
BuildLauncher |
newBuild()
Creates a launcher which can be used to execute a build.
|
<T extends Model> T getModel(Class<T> viewType) throws UnsupportedVersionException, UnknownModelException, BuildException, GradleConnectionException, IllegalStateException
This method blocks until the model is available.
T - The model type.viewType - The model type.UnsupportedVersionException - When the target Gradle version does not support the given model.UnknownModelException - When you are building a model unknown to the Tooling API,
for example you attempt to build a model of a type does not come from the Tooling API.BuildException - On some failure executing the Gradle build, in order to build the model.GradleConnectionException - On some other failure using the connection.IllegalStateException - When this connection has been closed or is closing.<T extends Model> void getModel(Class<T> viewType, ResultHandler<? super T> handler) throws IllegalStateException, UnknownModelException
T - The model type.viewType - The model type.handler - The handler to pass the result to.IllegalStateException - When this connection has been closed or is closing.UnknownModelException - When you are building a model unknown to the Tooling API,
for example you attempt to build a model of a type does not come from the Tooling API.BuildLauncher newBuild()
<T extends Model> ModelBuilder<T> model(Class<T> modelType) throws UnknownModelException
T - The model type.modelType - The model typeUnknownModelException - When you are building a model unknown to the Tooling API,
for example you attempt to build a model of a type does not come from the Tooling API.void close()