public interface BuildController
BuildAction
various ways to control a Gradle build and access information about the build.Modifier and Type | Method | Description |
---|---|---|
<T> T |
findModel(java.lang.Class<T> modelType) |
Fetches a snapshot of the model of the given type, if available.
|
<T,P> |
findModel(java.lang.Class<T> modelType,
java.lang.Class<P> parameterType,
Action<? super P> parameterInitializer) |
Fetches a snapshot of the model of the given type using the given parameter, if available.
|
<T> T |
findModel(Model target,
java.lang.Class<T> modelType) |
Fetches a snapshot of the model of the given type, if available.
|
<T,P> |
findModel(Model target,
java.lang.Class<T> modelType,
java.lang.Class<P> parameterType,
Action<? super P> parameterInitializer) |
Fetches a snapshot of the model of the given type for the given element using the given parameter, if available.
|
GradleBuild |
getBuildModel() |
Returns an overview of the Gradle build, including some basic details of the projects that make up the build.
|
boolean |
getCanQueryProjectModelInParallel(java.lang.Class<?> modelType) |
Returns
true when actions run using run(Collection) and that query project models of the given type will run in parallel. |
<T> T |
getModel(java.lang.Class<T> modelType) |
Fetches a snapshot of the model of the given type for the default project.
|
<T,P> |
getModel(java.lang.Class<T> modelType,
java.lang.Class<P> parameterType,
Action<? super P> parameterInitializer) |
Fetches a snapshot of the model of the given type using the given parameter.
|
<T> T |
getModel(Model target,
java.lang.Class<T> modelType) |
Fetches a snapshot of the model of the given type for the given element, usually a Gradle project.
|
<T,P> |
getModel(Model target,
java.lang.Class<T> modelType,
java.lang.Class<P> parameterType,
Action<? super P> parameterInitializer) |
Fetches a snapshot of the model of the given type for the given element using the given parameter.
|
<T> java.util.List<T> |
run(java.util.Collection<? extends BuildAction<? extends T>> actions) |
Runs the given actions and returns their results.
|
<T> T getModel(java.lang.Class<T> modelType) throws UnknownModelException
ProjectConnection
is created.
Any of following models types may be available, depending on the version of Gradle being used by the target build:
GradleBuild
BuildEnvironment
GradleProject
BuildInvocations
ProjectPublications
IdeaProject
BasicIdeaProject
EclipseProject
HierarchicalEclipseProject
A build may also expose additional custom tooling models. You can use this method to query these models.
T
- The model type.modelType
- The model type.UnknownModelException
- When the default project does not support the requested model.@Nullable <T> T findModel(java.lang.Class<T> modelType)
See getModel(Class)
for more details.
T
- The model type.modelType
- The model type.GradleBuild getBuildModel()
#getModel(GradleBuild.class)
.<T> T getModel(Model target, java.lang.Class<T> modelType) throws UnknownModelException
The following elements are supported:
BasicGradleProject
GradleProject
EclipseProject
IdeaModule
See getModel(Class)
for more details.
T
- The model type.target
- The target element, usually a project.modelType
- The model type.UnknownModelException
- When the target project does not support the requested model.@Nullable <T> T findModel(Model target, java.lang.Class<T> modelType)
See getModel(Model, Class)
for more details.
T
- The model type.modelType
- The model type.<T,P> T getModel(java.lang.Class<T> modelType, java.lang.Class<P> parameterType, Action<? super P> parameterInitializer) throws UnsupportedVersionException, UnknownModelException
See getModel(Model, Class, Class, Action)
for more details.
T
- The model type.P
- The parameter type.modelType
- The model type.parameterType
- The parameter type.parameterInitializer
- Action to configure the parameterUnknownModelException
- When the target project does not support the requested model.UnsupportedVersionException
- When the target project does not support the requested model or Gradle version does not support parameterized models.@Nullable <T,P> T findModel(java.lang.Class<T> modelType, java.lang.Class<P> parameterType, Action<? super P> parameterInitializer)
See getModel(Model, Class, Class, Action)
for more details.
T
- The model type.P
- The parameter type.modelType
- The model type.parameterType
- The parameter type.parameterInitializer
- Action to configure the parameter<T,P> T getModel(Model target, java.lang.Class<T> modelType, java.lang.Class<P> parameterType, Action<? super P> parameterInitializer) throws UnsupportedVersionException, UnknownModelException
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.
T
- The model type.P
- The parameter type.target
- The target element, usually a project.modelType
- The model type.parameterType
- The parameter type.parameterInitializer
- Action to configure the parameterUnknownModelException
- When the target project does not support the requested model.UnsupportedVersionException
- When the target project does not support the requested model or Gradle version does not support parameterized models.@Nullable <T,P> T findModel(Model target, java.lang.Class<T> modelType, java.lang.Class<P> parameterType, Action<? super P> parameterInitializer)
See getModel(Model, Class, Class, Action)
for more details.
T
- The model type.P
- The parameter type.target
- The target element, usually a project.modelType
- The model type.parameterType
- The parameter type.parameterInitializer
- Action to configure the parameter<T> java.util.List<T> run(java.util.Collection<? extends BuildAction<? extends T>> actions)
This method works with all Gradle versions. For versions 6.7 and earlier, the actions are run sequentially rather than in parallel.
When one or more actions fail with an exception, the exceptions are rethrown by this method and no result is returned.
T
- the result type.actions
- The actions to run.boolean getCanQueryProjectModelInParallel(java.lang.Class<?> modelType)
true
when actions run using run(Collection)
and that query project models of the given type will run in parallel.
Returns false
when the models will not be queried in parallel, for example because the target Gradle version does not support parallel execution,
or because some build configuration disables the parallel execution, or because the queries are unsafe to perform in parallel.true
when project models may be queried in parallel.