TaskContainer

API Documentation:TaskContainer

A TaskContainer is responsible for managing a set of Task instances.

You can obtain a TaskContainer instance by calling Project.getTasks(), or using the tasks property in your build script.

Properties

No properties

Methods

MethodDescription
containerWithType(type)
Incubating

Creates a regular container that wraps the polymorphic container presenting all elements of a specified type.

create(name)

Creates a Task with the given name and adds it to this container.

create(name, configureClosure)

Creates a Task with the given name adds it to this container. The given closure is used to configure the task before it is returned by this method.

create(name, type)

Creates a Task with the given name and type, and adds it to this container.

create(name, type, constructorArgs)
Incubating

Creates a Task with the given name and type, passing the given arguments to the @Inject-annotated constructor, and adds it to this container. All values passed to the task constructor must be non-null; otherwise a NullPointerException will be thrown

create(name, type, configuration)

Creates a Task with the given name and type, configures it with the given action, and adds it to this container.

create(name, configureAction)

Creates a new item with the given name, adding it to this container, then configuring it with the given action.

create(options)

Creates a Task and adds it to this container. A map of creation options can be passed to this method to control how the task is created. The following options are available:

create(options, configureClosure)

Creates a Task adds it to this container. A map of creation options can be passed to this method to control how the task is created. See TaskContainer.create(java.util.Map) for the list of options available. The given closure is used to configure the task before it is returned by this method.

findByPath(path)

Locates a task by path. You can supply a task name, a relative path, or an absolute path. Relative paths are interpreted relative to the project for this container. This method returns null if no task with the given path exists.

getByName(name)

Locates an object by name, failing if there is no such object.

getByName(name, configureClosure)

Locates an object by name, failing if there is no such object. The given configure closure is executed against the object before it is returned from this method. The object is passed to the closure as its delegate.

getByName(name, configureAction)

Locates an object by name, failing if there is no such object. The given configure action is executed against the object before it is returned from this method.

getByPath(path)

Locates a task by path. You can supply a task name, a relative path, or an absolute path. Relative paths are interpreted relative to the project for this container. This method throws an exception if no task with the given path exists.

maybeCreate(name)

Looks for an item with the given name, creating and adding it to this container if it does not exist.

maybeCreate(name, type)
Incubating

Looks for an item with the given name and type, creating and adding it to this container if it does not exist.

named(name)
Incubating

Locates a task by name, without triggering its creation or configuration, failing if there is no such object.

register(name)
Incubating

Defines a new task, which will be created when it is required. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method.

register(name, type)
Incubating

Defines a new task, which will be created when it is required. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method.

register(name, type, constructorArgs)
Incubating

Defines a new task, which will be created when it is required passing the given arguments to the @Inject-annotated constructor. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method. All values passed to the task constructor must be non-null; otherwise a NullPointerException will be thrown

register(name, type, configurationAction)
Incubating

Defines a new task, which will be created and configured when it is required. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method.

register(name, configurationAction)
Incubating

Defines a new task, which will be created and configured when it is required. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method.

replace(name)

Creates a Task with the given name and adds it to this container, replacing any existing task with the same name.

replace(name, type)

Creates a Task with the given name and type, and adds it to this container, replacing any existing task of the same name.

Script blocks

No script blocks

Method details

NamedDomainObjectContainer<U> containerWithType(Class<U> type)

Note: This method is incubating and may change in a future version of Gradle.

Creates a regular container that wraps the polymorphic container presenting all elements of a specified type.

Task create(String name)

Creates a Task with the given name and adds it to this container.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details.

Task create(String name, Closure configureClosure)

Creates a Task with the given name adds it to this container. The given closure is used to configure the task before it is returned by this method.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details.

T create(String name, Class<T> type)

Creates a Task with the given name and type, and adds it to this container.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details.

T create(String name, Class<T> type, Object... constructorArgs)

Note: This method is incubating and may change in a future version of Gradle.

Creates a Task with the given name and type, passing the given arguments to the @Inject-annotated constructor, and adds it to this container. All values passed to the task constructor must be non-null; otherwise a NullPointerException will be thrown

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details.

T create(String name, Class<T> type, Action<? super T> configuration)

Creates a Task with the given name and type, configures it with the given action, and adds it to this container.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details.

T create(String name, Action<? super T> configureAction)

Creates a new item with the given name, adding it to this container, then configuring it with the given action.

Task create(Map<String, ?> options)

Creates a Task and adds it to this container. A map of creation options can be passed to this method to control how the task is created. The following options are available:

OptionDescriptionDefault Value
nameThe name of the task to create.None. Must be specified.
typeThe class of the task to create.DefaultTask
actionThe closure or Action to execute when the task executes. See Task.doFirst(org.gradle.api.Action).null
overwriteReplace an existing task?false
dependsOnThe dependencies of the task. See here for more details.[]
groupThe group of the task.null
descriptionThe description of the task. null
constructorArgsThe arguments to pass to the task class constructor. null

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details.

If a task with the given name already exists in this container and the overwrite option is not set to true, an exception is thrown.

Task create(Map<String, ?> options, Closure configureClosure)

Creates a Task adds it to this container. A map of creation options can be passed to this method to control how the task is created. See TaskContainer.create(java.util.Map) for the list of options available. The given closure is used to configure the task before it is returned by this method.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details.

Task findByPath(String path)

Locates a task by path. You can supply a task name, a relative path, or an absolute path. Relative paths are interpreted relative to the project for this container. This method returns null if no task with the given path exists.

T getByName(String name)

Locates an object by name, failing if there is no such object.

T getByName(String name, Closure configureClosure)

Locates an object by name, failing if there is no such object. The given configure closure is executed against the object before it is returned from this method. The object is passed to the closure as its delegate.

T getByName(String name, Action<? super T> configureAction)

Locates an object by name, failing if there is no such object. The given configure action is executed against the object before it is returned from this method.

Task getByPath(String path)

Locates a task by path. You can supply a task name, a relative path, or an absolute path. Relative paths are interpreted relative to the project for this container. This method throws an exception if no task with the given path exists.

T maybeCreate(String name)

Looks for an item with the given name, creating and adding it to this container if it does not exist.

U maybeCreate(String name, Class<U> type)

Note: This method is incubating and may change in a future version of Gradle.

Looks for an item with the given name and type, creating and adding it to this container if it does not exist.

TaskProvider<T> named(String name)

Note: This method is incubating and may change in a future version of Gradle.

Locates a task by name, without triggering its creation or configuration, failing if there is no such object.

TaskProvider<Task> register(String name)

Note: This method is incubating and may change in a future version of Gradle.

Defines a new task, which will be created when it is required. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method.

It is generally more efficient to use this method instead of TaskContainer.create(java.lang.String), as that methods will eagerly create he task, regardless of whether that task is required for the current build or not. This method, on the other hand, will defer creation until required.

TaskProvider<T> register(String name, Class<T> type)

Note: This method is incubating and may change in a future version of Gradle.

Defines a new task, which will be created when it is required. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method.

It is generally more efficient to use this method instead of TaskContainer.create(java.lang.String, java.lang.Class, org.gradle.api.Action) or TaskContainer.create(java.lang.String, java.lang.Class), as those methods will eagerly create and configure the task, regardless of whether that task is required for the current build or not. This method, on the other hand, will defer creation until required.

TaskProvider<T> register(String name, Class<T> type, Object... constructorArgs)

Note: This method is incubating and may change in a future version of Gradle.

Defines a new task, which will be created when it is required passing the given arguments to the @Inject-annotated constructor. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method. All values passed to the task constructor must be non-null; otherwise a NullPointerException will be thrown

It is generally more efficient to use this method instead of TaskContainer.create(java.lang.String, java.lang.Class, org.gradle.api.Action) or TaskContainer.create(java.lang.String, java.lang.Class), as those methods will eagerly create and configure the task, regardless of whether that task is required for the current build or not. This method, on the other hand, will defer creation until required.

TaskProvider<T> register(String name, Class<T> type, Action<? super T> configurationAction)

Note: This method is incubating and may change in a future version of Gradle.

Defines a new task, which will be created and configured when it is required. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method.

It is generally more efficient to use this method instead of TaskContainer.create(java.lang.String, java.lang.Class, org.gradle.api.Action) or TaskContainer.create(java.lang.String, java.lang.Class), as those methods will eagerly create and configure the task, regardless of whether that task is required for the current build or not. This method, on the other hand, will defer creation and configuration until required.

TaskProvider<Task> register(String name, Action<? super Task> configurationAction)

Note: This method is incubating and may change in a future version of Gradle.

Defines a new task, which will be created and configured when it is required. A task is 'required' when the task is located using query methods such as TaskCollection.getByName(java.lang.String), when the task is added to the task graph for execution or when Provider.get() is called on the return value of this method.

It is generally more efficient to use this method instead of NamedDomainObjectContainer.create(java.lang.String, org.gradle.api.Action) or TaskContainer.create(java.lang.String), as those methods will eagerly create and configure the task, regardless of whether that task is required for the current build or not. This method, on the other hand, will defer creation and configuration until required.

Task replace(String name)

Creates a Task with the given name and adds it to this container, replacing any existing task with the same name.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details.

T replace(String name, Class<T> type)

Creates a Task with the given name and type, and adds it to this container, replacing any existing task of the same name.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details.