|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
public interface ProjectConnection
Represents a long-lived connection to a Gradle project. You obtain an instance of a 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.
Method Summary | |
---|---|
BuildActionExecuter
|
action(BuildAction buildAction)
Creates an executer which can be used to run the given action. |
void
|
close()
Closes this connection. |
Object
|
getModel(Class modelType)
Fetches a snapshot of the model of the given type for this project. |
void
|
getModel(Class modelType, ResultHandler handler)
Starts fetching a snapshot of the given model, passing the result to the given handler when complete. |
ModelBuilder
|
model(Class modelType)
Creates a builder which can be used to query the model of the given type. |
BuildLauncher
|
newBuild()
Creates a launcher which can be used to execute a build. |
Method Detail |
---|
@Incubating public BuildActionExecuter action(BuildAction buildAction)
buildAction
- The action to run.
- The result type.
public void close()
public Object getModel(Class modelType)
This method is simply a convenience for calling model(modelType).get()
modelType
- The model type.
- The model type.
public void getModel(Class modelType, ResultHandler handler)
If the operation fails, the handler's ResultHandler#onFailure(GradleConnectionException)#onFailure(GradleConnectionException) method is called with the appropriate exception. See getModel(Class) for a description of the various exceptions that the operation may fail with.
This method is simply a convenience for calling model(modelType).get(handler)
modelType
- The model type.handler
- The handler to pass the result to.
- The model type.
public ModelBuilder model(Class modelType)
Any of following models types may be available, depending on the version of Gradle being used by the target build:
A build may also expose additional custom tooling models. You can use this method to query these models.
modelType
- The model type
- The model type.
public BuildLauncher newBuild()
Gradle API 1.12