Interface TaskContainer
- All Superinterfaces:
Collection<Task>
,org.gradle.util.Configurable<NamedDomainObjectContainer<Task>>
,DomainObjectCollection<Task>
,Iterable<Task>
,NamedDomainObjectCollection<Task>
,NamedDomainObjectContainer<Task>
,NamedDomainObjectSet<Task>
,PolymorphicDomainObjectContainer<Task>
,Set<Task>
,TaskCollection<Task>
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.
-
Method Summary
Modifier and TypeMethodDescriptionCreates aTask
with the given name and adds it to this container.Creates aTask
with the given name adds it to this container.<T extends Task>
TCreates aTask
with the given name and type, and adds it to this container.<T extends Task>
TCreates aTask
with the given name and type, configures it with the given action, and adds it to this container.Creates aTask
and adds it to this container.Creates aTask
adds it to this container.findByPath
(String path) Locates a task by path.Locates a task by path.Creates aTask
with the given name and adds it to this container, replacing any existing task with the same name.<T extends Task>
TCreates aTask
with the given name and type, and adds it to this container, replacing any existing task of the same name.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface org.gradle.api.DomainObjectCollection
all, all, whenObjectAdded, whenObjectAdded, whenObjectRemoved, whenObjectRemoved, withType, withType
Methods inherited from interface org.gradle.api.NamedDomainObjectCollection
add, addAll, addRule, addRule, addRule, findByName, getAsMap, getByName, getNamer, getNames, getRules
Methods inherited from interface org.gradle.api.NamedDomainObjectContainer
configure, create, maybeCreate
Methods inherited from interface org.gradle.api.NamedDomainObjectSet
findAll
Methods inherited from interface org.gradle.api.PolymorphicDomainObjectContainer
containerWithType, maybeCreate
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArray
Methods inherited from interface org.gradle.api.tasks.TaskCollection
getAt, getByName, getByName, matching, matching, whenTaskAdded, whenTaskAdded, withType
-
Method Details
-
findByPath
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.
- Parameters:
path
- the path of the task to be returned- Returns:
- The task. Returns null if so such task exists.
-
getByPath
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.
- Parameters:
path
- the path of the task to be returned- Returns:
- The task. Never returns null
- Throws:
UnknownTaskException
- If no task with the given path exists.
-
create
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:Option Description Default Value "name"
The name of the task to create. None. Must be specified. "type"
The class of the task to create. DefaultTask
"action"
The closure or Action
to execute when the task executes. SeeTask.doFirst(Action)
.null
"overwrite"
Replace an existing task? false
"dependsOn"
The dependencies of the task. See here for more details. []
"group"
The group of the task. null
"description"
The description of the task. 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.- Parameters:
options
- The task creation options.- Returns:
- The newly created task object
- Throws:
InvalidUserDataException
- If a task with the given name already exists in this project.
-
create
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. Seecreate(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.
- Parameters:
options
- The task creation options.configureClosure
- The closure to use to configure the task.- Returns:
- The newly created task object
- Throws:
InvalidUserDataException
- If a task with the given name already exists in this project.
-
create
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.
- Specified by:
create
in interfaceNamedDomainObjectContainer<Task>
- Parameters:
name
- The name of the task to be createdconfigureClosure
- The closure to use to configure the task.- Returns:
- The newly created task object
- Throws:
InvalidUserDataException
- If a task with the given name already exists in this project.
-
create
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.
- Specified by:
create
in interfaceNamedDomainObjectContainer<Task>
- Parameters:
name
- The name of the task to be created- Returns:
- The newly created task object
- Throws:
InvalidUserDataException
- If a task with the given name already exists in this project.
-
create
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.
- Specified by:
create
in interfacePolymorphicDomainObjectContainer<Task>
- Type Parameters:
T
- the type of the domain object to be created- Parameters:
name
- The name of the task to be created.type
- The type of task to create.- Returns:
- The newly created task object
- Throws:
InvalidUserDataException
- If a task with the given name already exists in this project.
-
create
<T extends Task> T create(String name, Class<T> type, Action<? super T> configuration) throws InvalidUserDataException 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.
- Specified by:
create
in interfacePolymorphicDomainObjectContainer<Task>
- Type Parameters:
T
- the type of the domain object to be created- Parameters:
name
- The name of the task to be created.type
- The type of task to create.configuration
- The action to configure the task with.- Returns:
- The newly created task object.
- Throws:
InvalidUserDataException
- If a task with the given name already exists in this project.
-
replace
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.
- Parameters:
name
- The name of the task to be created- Returns:
- The newly created task object
-
replace
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.
- Parameters:
name
- The name of the task to be created.type
- The type of task to create.- Returns:
- The newly created task object
-