api / org.gradle.tooling / ProjectConnection / getModel

getModel

abstract fun <T : Any> getModel(modelType: Class<T>): T

Fetches a snapshot of the model of the given type for this project. This method blocks until the model is available.

This method is simply a convenience for calling model(modelType).get()

Parameters

modelType - The model type.

- The model type.

Exceptions

UnsupportedVersionException - When the target Gradle version does not support the given model.

UnknownModelException - When the target Gradle version or build does not support the requested model.

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.

Return
The model.

Since
1.0-milestone-3

abstract fun <T : Any> getModel(modelType: Class<T>, handler: ResultHandler<in T>): Unit

Starts fetching a snapshot of the given model, passing the result to the given handler when complete. This method returns immediately, and the result is later passed to the given handler's ResultHandler#onComplete(Object) method.

If the operation fails, the handler's ResultHandler#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)

Parameters

modelType - The model type.

handler - The handler to pass the result to.

- The model type.

Exceptions

IllegalStateException - When this connection has been closed or is closing.

Since
1.0-milestone-3