Groovy Documentation

org.gradle.api.tasks
[Java] Interface TaskContainer

org.gradle.api.tasks.TaskContainer
  org.gradle.api.NamedDomainObjectCollection
      org.gradle.api.tasks.TaskCollection
          org.gradle.api.DomainObjectCollection
              org.gradle.api.NamedDomainObjectSet
                  java.lang.Iterable
                      org.gradle.util.Configurable
                          org.gradle.api.NamedDomainObjectContainer
                              java.util.Collection
                                  org.gradle.api.PolymorphicDomainObjectContainer
All Superinterfaces:
NamedDomainObjectCollection, TaskCollection, DomainObjectCollection, NamedDomainObjectSet, Iterable, Configurable, NamedDomainObjectContainer, Collection, PolymorphicDomainObjectContainer

public interface TaskContainer
extends PolymorphicDomainObjectContainer, TaskCollection

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
Task add(Map options)

Task add(Map options, Closure configureClosure)

Task add(String name, Closure configureClosure)

Task add(String name)

Object add(String name, Class type)

Task create(Map options)

Task create(Map options, Closure configureClosure)

Task create(String name, Closure configureClosure)

Task create(String name)

Object create(String name, Class type)

Object create(String name, Class type, Action configuration)

Task findByPath(String path)

Task getByPath(String path)

Task replace(String name)

Object replace(String name, Class type)

 
Methods inherited from interface TaskCollection
getAt, getByName, getByName, matching, matching, whenTaskAdded, whenTaskAdded, withType
 
Methods inherited from interface PolymorphicDomainObjectContainer
create, create
 
Methods inherited from interface NamedDomainObjectContainer
configure, create, create, create, maybeCreate
 

Method Detail

add

@Deprecated
public Task add(Map 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
{
value:
org.gradle.api.Task#TASK_NAME}
The name of the task to create.None. Must be specified.
{@value org.gradle.api.Task#TASK_TYPE}The class of the task to create.DefaultTask
{@value org.gradle.api.Task#TASK_ACTION}The closure or Action to execute when the task executes. See Task#doFirst(Action)#doFirst(Action).null
{@value org.gradle.api.Task#TASK_OVERWRITE}Replace an existing task?false
{@value org.gradle.api.Task#TASK_DEPENDS_ON}The dependencies of the task. See here for more details.[]

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 {@value org.gradle.api.Task#TASK_OVERWRITE} option is not set to true, an exception is thrown.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
deprecated:
use create(java.util.Map) instead
Parameters:
options - The task creation options.
Returns:
The newly created task object


add

@Deprecated
public Task add(Map 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 add(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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
deprecated:
use create(java.util.Map, groovy.lang.Closure) instead
Parameters:
options - The task creation options.
configureClosure - The closure to use to configure the task.
Returns:
The newly created task object


add

@Deprecated
public Task add(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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
deprecated:
use create(String, groovy.lang.Closure) instead
Parameters:
name - The name of the task to be created
configureClosure - The closure to use to configure the task.
Returns:
The newly created task object


add

@Deprecated
public Task add(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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
deprecated:
use create(String) instead
Parameters:
name - The name of the task to be created
Returns:
The newly created task object


add

@Deprecated
public Object add(String name, Class 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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
deprecated:
use create(String, Class) instead
Parameters:
name - The name of the task to be created.
type - The type of task to create.
Returns:
The newly created task object


create

public Task create(Map 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
{
value:
org.gradle.api.Task#TASK_NAME}
The name of the task to create.None. Must be specified.
{@value org.gradle.api.Task#TASK_TYPE}The class of the task to create.DefaultTask
{@value org.gradle.api.Task#TASK_ACTION}The closure or Action to execute when the task executes. See Task#doFirst(Action)#doFirst(Action).null
{@value org.gradle.api.Task#TASK_OVERWRITE}Replace an existing task?false
{@value org.gradle.api.Task#TASK_DEPENDS_ON}The dependencies of the task. See here for more details.[]

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 {@value org.gradle.api.Task#TASK_OVERWRITE} option is not set to true, an exception is thrown.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
Parameters:
options - The task creation options.
Returns:
The newly created task object


create

public Task create(Map 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 add(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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
Parameters:
options - The task creation options.
configureClosure - The closure to use to configure the task.
Returns:
The newly created task object


create

public 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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
Parameters:
name - The name of the task to be created
configureClosure - The closure to use to configure the task.
Returns:
The newly created task object


create

public 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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
Parameters:
name - The name of the task to be created
Returns:
The newly created task object


create

public Object create(String name, Class 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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
Parameters:
name - The name of the task to be created.
type - The type of task to create.
Returns:
The newly created task object


create

public Object create(String name, Class type, Action 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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
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.


findByPath

public 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.

Parameters:
path - the path of the task to be returned
Returns:
The task. Returns null if so such task exists.


getByPath

public 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.

throws:
UnknownTaskException If no task with the given path exists.
Parameters:
path - the path of the task to be returned
Returns:
The task. Never returns null


replace

public 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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
Parameters:
name - The name of the task to be created
Returns:
The newly created task object


replace

public Object replace(String name, Class 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.

throws:
InvalidUserDataException If a task with the given name already exists in this project.
Parameters:
name - The name of the task to be created.
type - The type of task to create.
Returns:
The newly created task object


 

Gradle API 1.8