Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD

## org.gradle.api.tasks
Interface TaskContainer

    org.gradle.api.tasks.TaskContainer
      org.gradle.api.tasks.TaskCollection
          org.gradle.api.DomainObjectCollection

All Superinterfaces:
  TaskCollection, DomainObjectCollection

    interface TaskContainer
    extends TaskCollection

A `TaskContainer` is responsible for managing a set of org.gradle.api.Task instances.

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

Method Summary
`Task` | `add(Map options)` Creates a {
`Task` | `add(Map options, Closure configureClosure)` Creates a {
`Task` | `add(java.lang.String name, Closure configureClosure)` Creates a {
`Task` | `add(java.lang.String name)` Creates a {
`T` | `add(java.lang.String name, java.lang.Class type)` Creates a {
`Task` | `findByPath(java.lang.String path)` Locates a task by path.
`Task` | `getByPath(java.lang.String path)` Locates a task by path.
`Task` | `replace(java.lang.String name)` Creates a { same name.
`T` | `replace(java.lang.String name, java.lang.Class type)` Creates a { task of the same name.

Methods inherited from interface TaskCollection
allTasks, allTasks, getAt, getByName, getByName, matching, whenTaskAdded, whenTaskAdded, withType

Methods inherited from interface DomainObjectCollection
allObjects, allObjects, findAll, findByName, getAll, getAsMap, getAt, getByName, getByName, matching, whenObjectAdded, whenObjectAdded, whenObjectRemoved, withType

Methods inherited from interface java.lang.Iterable
iterator

Methods inherited from class java.lang.Object
hashCode, getClass, equals, toString, wait, wait, wait, notify, notifyAll

Method Detail

### add

    public Task add(Map options)

  Creates a org.gradle.api.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
  --- | --- | ---
  `{ 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.
  org.gradle.api.DefaultTask
  `{`

value:
  org.gradle.api.Task#TASK_ACTION}
  The closure or org.gradle.api.TaskAction to execute when the task executes. See Task#doFirst(TaskAction).
  `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 `override` option is not set to true, an exception is thrown.

param:
  options The task creation options.

return:
  The newly created task object

throws:
  InvalidUserDataException If a task with the given name already exsists in this project.

### add

    public Task add(Map options, Closure configureClosure)

  Creates a org.gradle.api.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.

  param:
    options The task creation options.
  param:
    configureClosure The closure to use to configure the task.
  return:
    The newly created task object
  throws:
    InvalidUserDataException If a task with the given name already exsists in this project.

### add

    public Task add(java.lang.String name, Closure configureClosure)

  Creates a org.gradle.api.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.

  param:
    name The name of the task to be created
  param:
    configureClosure The closure to use to configure the task.
  return:
    The newly created task object
  throws:
    InvalidUserDataException If a task with the given name already exsists in this project.

### add

    public Task add(java.lang.String name)

  Creates a org.gradle.api.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.

  param:
    name The name of the task to be created
  return:
    The newly created task object
  throws:
    InvalidUserDataException If a task with the given name already exsists in this project.

### add

    public T add(java.lang.String name, java.lang.Class type)

  Creates a org.gradle.api.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.

  param:
    name The name of the task to be created.
  param:
    type The type of task to create.
  return:
    The newly created task object
  throws:
    InvalidUserDataException If a task with the given name already exsists in this project.

### findByPath

    public Task findByPath(java.lang.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.

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

### getByPath

    public Task getByPath(java.lang.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.

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

### replace

    public Task replace(java.lang.String name)

  Creates a org.gradle.api.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.

  param:
    name The name of the task to be created
  return:
    The newly created task object
  throws:
    InvalidUserDataException If a task with the given name already exsists in this project.

### replace

    public T replace(java.lang.String name, java.lang.Class type)

  Creates a org.gradle.api.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.

  param:
    name The name of the task to be created.
  param:
    type The type of task to create.
  return:
    The newly created task object
  throws:
    InvalidUserDataException If a task with the given name already exsists in this project.

Groovy Documentation