api / org.gradle.tooling / BuildController

BuildController

interface BuildController

Provides a BuildAction various ways to control a Gradle build and access information about the build.

Since
1.8

Functions

findModel

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

Fetches a snapshot of the model of the given type, if available.

See #getModel(Class) for more details.

abstract fun <T : Any> findModel(target: Model, modelType: Class<T>): T

Fetches a snapshot of the model of the given type, if available.

See #getModel(Model, Class) for more details.

abstract fun <T : Any, P : Any> findModel(modelType: Class<T>, parameterType: Class<P>, parameterInitializer: Action<in P>): T

Fetches a snapshot of the model of the given type using the given parameter, if available.

See #getModel(Model, Class, Class, Action) for more details.

abstract fun <T : Any, P : Any> findModel(target: Model, modelType: Class<T>, parameterType: Class<P>, parameterInitializer: Action<in P>): T

Fetches a snapshot of the model of the given type for the given element using the given parameter, if available.

See #getModel(Model, Class, Class, Action) for more details.

getBuildModel

abstract fun getBuildModel(): GradleBuild

Returns an overview of the Gradle build, including some basic details of the projects that make up the build. This is equivalent to calling #getModel(GradleBuild.class).

getModel

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

Fetches a snapshot of the model of the given type for the default project. The default project is generally the project referenced when a ProjectConnection is created.

Any of following models types may be available, depending on the version of Gradle being used by the target build:

  • GradleBuild
  • org.gradle.tooling.model.build.BuildEnvironment
  • org.gradle.tooling.model.GradleProject
  • org.gradle.tooling.model.gradle.BuildInvocations
  • org.gradle.tooling.model.gradle.ProjectPublications
  • org.gradle.tooling.model.idea.IdeaProject
  • org.gradle.tooling.model.idea.BasicIdeaProject
  • org.gradle.tooling.model.eclipse.EclipseProject
  • org.gradle.tooling.model.eclipse.HierarchicalEclipseProject

A build may also expose additional custom tooling models. You can use this method to query these models.

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

Fetches a snapshot of the model of the given type for the given element, usually a Gradle project.

The following elements are supported:

  • Any org.gradle.tooling.model.gradle.BasicGradleProject
  • Any org.gradle.tooling.model.GradleProject
  • Any org.gradle.tooling.model.eclipse.EclipseProject
  • Any org.gradle.tooling.model.idea.IdeaModule

See #getModel(Class) for more details.

abstract fun <T : Any, P : Any> getModel(modelType: Class<T>, parameterType: Class<P>, parameterInitializer: Action<in P>): T

Fetches a snapshot of the model of the given type using the given parameter.

See #getModel(Model, Class, Class, Action) for more details.

abstract fun <T : Any, P : Any> getModel(target: Model, modelType: Class<T>, parameterType: Class<P>, parameterInitializer: Action<in P>): T

Fetches a snapshot of the model of the given type for the given element using the given parameter.

The parameter type must be an interface only with getters and setters and no nesting is supported. The Tooling API will create a proxy instance of this interface and use the initializer to run against that instance to configure it and then pass to the model builder.

See #getModel(Class) for more details.