Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gradle.api.tasks
Interface TaskCollection<T extends Task>

All Superinterfaces:
  DomainObjectCollection<T>, java.lang.Iterable<T>

All Known Subinterfaces:
  TaskContainer

    public interface TaskCollection<T extends Task>

extends DomainObjectCollection<T>

A `TaskCollection` contains a set of `Task` instances, and provides a number of query methods.

Method Summary
`void` | `allTasks(Action<? super T> action)` Executes the given action against all tasks in this collection, and any tasks subsequently added to this collection.
`void` | `allTasks(groovy.lang.Closure closure)` Executes the given closure against all tasks in this collection, and any tasks subsequently added to this collection.
`T` | `getAt(java.lang.String name)` Locates an object by name, failing if there is no such task.
`T` | `getByName(java.lang.String name)` Locates an object by name, failing if there is no such object.
`T` | `getByName(java.lang.String name, groovy.lang.Closure configureClosure)` Locates an object by name, failing if there is no such object.
`TaskCollection<T>` | `matching(Spec<? super T> spec)` Returns a collection which contains the objects in this collection which meet the given specification.
`Action<? super T>` | `whenTaskAdded(Action<? super T> action)` Adds an `Action` to be executed when a task is added to this collection.
`void` | `whenTaskAdded(groovy.lang.Closure closure)` Adds a closure to be called when a task is added to this collection.
`
`<S extends T> TaskCollection<S>`
` | `withType(java.lang.Class<S> type)` Returns a collection containing the objects in this collection of the given type.

Methods inherited from interface org.gradle.api.DomainObjectCollection
`allObjects, allObjects, findAll, findByName, getAll, getAsMap, whenObjectAdded, whenObjectAdded, whenObjectRemoved`

Methods inherited from interface java.lang.Iterable
`iterator`

Method Detail

### matching

    TaskCollection<T> matching(Spec<? super T> spec)

  Returns a collection which contains the objects in this collection which meet the given specification. The returned collection is live, so that when matching objects are added to this collection, they are also visible in the filtered collection.

  Specified by:
    `matching` in interface `DomainObjectCollection<T extends Task>`
  Parameters:
    `spec` - The specification to use.
  Returns:
    The collection of matching objects. Returns an empty collection if there are no such objects in this collection.

### getByName

    T getByName(java.lang.String name,
                groovy.lang.Closure configureClosure)
                             throws UnknownTaskException

  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 it's delegate.

  Specified by:
    `getByName` in interface `DomainObjectCollection<T extends Task>`
  Parameters:
    `name` - The object name
    `configureClosure` - The closure to use to configure the object.
  Returns:
    The object with the given name, after the configure closure has been applied to it. Never returns null.
  Throws:
    `UnknownTaskException`

### getByName

    T getByName(java.lang.String name)
                             throws UnknownTaskException

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

  Specified by:
    `getByName` in interface `DomainObjectCollection<T extends Task>`
  Parameters:
    `name` - The object name
  Returns:
    The object with the given name. Never returns null.
  Throws:
    `UnknownTaskException`

### withType

    <S extends T> TaskCollection<S> withType(java.lang.Class<S> type)

  Returns a collection containing the objects in this collection of the given type. The returned collection is live, so that when matching objects are later added to this collection, they are also visible in the filtered collection.

  Specified by:
    `withType` in interface `DomainObjectCollection<T extends Task>`
  Parameters:
    `type` - The type of objects to find.
  Returns:
    The matching objects. Returns an empty set if there are no such objects in this collection.

### whenTaskAdded

    Action<? super T> whenTaskAdded(Action<? super T> action)

  Adds an `Action` to be executed when a task is added to this collection.

  Parameters:
    `action` - The action to be executed
  Returns:
    the supplied action

### whenTaskAdded

    void whenTaskAdded(groovy.lang.Closure closure)

  Adds a closure to be called when a task is added to this collection. The task is passed to the closure as the parameter.

  Parameters:
    `closure` - The closure to be called

### allTasks

    void allTasks(Action<? super T> action)

  Executes the given action against all tasks in this collection, and any tasks subsequently added to this collection.

  Parameters:
    `action` - The action to be executed

### allTasks

    void allTasks(groovy.lang.Closure closure)

  Executes the given closure against all tasks in this collection, and any tasks subsequently added to this collection.

  Parameters:
    `closure` - The closure to be called

### getAt

    T getAt(java.lang.String name)
                         throws UnknownTaskException

  Locates an object by name, failing if there is no such task. This method is identical to `DomainObjectCollection.getByName(String)`. You can call this method in your build script by using the groovy `[]` operator.

  Specified by:
    `getAt` in interface `DomainObjectCollection<T extends Task>`
  Parameters:
    `name` - The object name
  Returns:
    The object with the given name. Never returns null.
  Throws:
    `UnknownTaskException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD