Package org.gradle.api.tasks
Interface TaskCollection<T extends Task>
-
- Type Parameters:
T
- The type of tasks which this collection contains.
- All Superinterfaces:
java.util.Collection<T>
,DomainObjectCollection<T>
,DomainObjectSet<T>
,java.lang.Iterable<T>
,NamedDomainObjectCollection<T>
,NamedDomainObjectSet<T>
,java.util.Set<T>
- All Known Subinterfaces:
TaskContainer
public interface TaskCollection<T extends Task> extends NamedDomainObjectSet<T>
ATaskCollection
contains a set ofTask
instances, and provides a number of query methods.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
getAt(java.lang.String name)
Locates an object by name, failing if there is no such object.T
getByName(java.lang.String name)
Locates an object by name, failing if there is no such object.T
getByName(java.lang.String name, Closure configureClosure)
Locates an object by name, failing if there is no such object.TaskCollection<T>
matching(Closure closure)
Returns a collection which contains the objects in this collection which meet the given closure specification.TaskCollection<T>
matching(Spec<? super T> spec)
Returns a collection which contains the objects in this collection which meet the given specification.TaskProvider<T>
named(java.lang.String name)
Locates a task by name, without triggering its creation or configuration, failing if there is no such object.<S extends T>
TaskProvider<S>named(java.lang.String name, java.lang.Class<S> type)
Locates a object by name and type, without triggering its creation or configuration, failing if there is no such object.<S extends T>
TaskProvider<S>named(java.lang.String name, java.lang.Class<S> type, Action<? super S> configurationAction)
Locates a object by name and type, without triggering its creation or configuration, failing if there is no such object.TaskProvider<T>
named(java.lang.String name, Action<? super T> configurationAction)
Locates a object by name, without triggering its creation or configuration, failing if there is no such object.TaskCollection<T>
named(Spec<java.lang.String> nameFilter)
Returns a collection containing the objects with names matching the provided filter.void
whenTaskAdded(Closure closure)
Adds a closure to be called when a task is added to this collection.Action<? super T>
whenTaskAdded(Action<? super T> action)
Adds anAction
to be executed 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
addAllLater, addLater, all, all, configureEach, whenObjectAdded, whenObjectAdded, whenObjectRemoved, whenObjectRemoved, withType, withType
-
Methods inherited from interface org.gradle.api.NamedDomainObjectCollection
add, addAll, addRule, addRule, addRule, findByName, getAsMap, getByName, getCollectionSchema, getNamer, getNames, getRules
-
Methods inherited from interface org.gradle.api.NamedDomainObjectSet
findAll
-
-
-
-
Method Detail
-
named
TaskCollection<T> named(Spec<java.lang.String> nameFilter)
Returns a collection containing the objects with names matching the provided filter. The returned collection is live, so that when matching objects are added to this collection, they are also visible in the filtered collection. This method will NOT cause any pending objects in this container to be realized.- Specified by:
named
in interfaceNamedDomainObjectCollection<T extends Task>
- Specified by:
named
in interfaceNamedDomainObjectSet<T extends Task>
- Parameters:
nameFilter
- The specification to test names against.- Returns:
- The collection of objects with names satisfying the filter. Returns an empty collection if there are no such objects in this collection.
-
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 interfaceDomainObjectCollection<T extends Task>
- Specified by:
matching
in interfaceDomainObjectSet<T extends Task>
- Specified by:
matching
in interfaceNamedDomainObjectCollection<T extends Task>
- Specified by:
matching
in interfaceNamedDomainObjectSet<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.
-
matching
TaskCollection<T> matching(Closure closure)
Returns a collection which contains the objects in this collection which meet the given closure 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 interfaceDomainObjectCollection<T extends Task>
- Specified by:
matching
in interfaceDomainObjectSet<T extends Task>
- Specified by:
matching
in interfaceNamedDomainObjectCollection<T extends Task>
- Specified by:
matching
in interfaceNamedDomainObjectSet<T extends Task>
- Parameters:
closure
- The specification to use. The closure gets a collection element as an argument.- 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, 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 its delegate.- Specified by:
getByName
in interfaceNamedDomainObjectCollection<T extends Task>
- Parameters:
name
- The object nameconfigureClosure
- 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 interfaceNamedDomainObjectCollection<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 interfaceDomainObjectCollection<T extends Task>
- Specified by:
withType
in interfaceDomainObjectSet<T extends Task>
- Specified by:
withType
in interfaceNamedDomainObjectCollection<T extends Task>
- Specified by:
withType
in interfaceNamedDomainObjectSet<T extends Task>
- Parameters:
type
- The type of objects to find.- Returns:
- The matching objects. Returns an empty collection if there are no such objects in this collection.
-
whenTaskAdded
Action<? super T> whenTaskAdded(Action<? super T> action)
Adds anAction
to be executed when a task is added to this collection.Like
DomainObjectCollection.all(Action)
, this method will cause all tasks in this container to be realized.- Parameters:
action
- The action to be executed- Returns:
- the supplied action
-
whenTaskAdded
void whenTaskAdded(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- See Also:
whenTaskAdded(Action)
-
getAt
T getAt(java.lang.String name) throws UnknownTaskException
Locates an object by name, failing if there is no such object. This method is identical toNamedDomainObjectCollection.getByName(String)
. You can call this method in your build script by using the groovy[]
operator.- Specified by:
getAt
in interfaceNamedDomainObjectCollection<T extends Task>
- Parameters:
name
- The object name- Returns:
- The object with the given name. Never returns null.
- Throws:
UnknownTaskException
-
named
TaskProvider<T> named(java.lang.String name) throws UnknownTaskException
Locates a task by name, without triggering its creation or configuration, failing if there is no such object.- Specified by:
named
in interfaceNamedDomainObjectCollection<T extends Task>
- Parameters:
name
- The task name- Returns:
- A
Provider
that will return the task when queried. The task may be created and configured at this point, if not already. - Throws:
UnknownTaskException
- If a task with the given name is not defined.- Since:
- 4.9
-
named
TaskProvider<T> named(java.lang.String name, Action<? super T> configurationAction) throws UnknownTaskException
Locates a object by name, without triggering its creation or configuration, failing if there is no such object. The given configure action is executed against the object before it is returned from the provider.- Specified by:
named
in interfaceNamedDomainObjectCollection<T extends Task>
- Parameters:
name
- The object's name- Returns:
- A
Provider
that will return the object when queried. The object may be created and configured at this point, if not already. - Throws:
UnknownTaskException
- Since:
- 5.0
-
named
<S extends T> TaskProvider<S> named(java.lang.String name, java.lang.Class<S> type) throws UnknownTaskException
Locates a object by name and type, without triggering its creation or configuration, failing if there is no such object.- Specified by:
named
in interfaceNamedDomainObjectCollection<T extends Task>
- Parameters:
name
- The object's nametype
- The object's type- Returns:
- A
Provider
that will return the object when queried. The object may be created and configured at this point, if not already. - Throws:
UnknownTaskException
- Since:
- 5.0
-
named
<S extends T> TaskProvider<S> named(java.lang.String name, java.lang.Class<S> type, Action<? super S> configurationAction) throws UnknownTaskException
Locates a object by name and type, without triggering its creation or configuration, failing if there is no such object. The given configure action is executed against the object before it is returned from the provider.- Specified by:
named
in interfaceNamedDomainObjectCollection<T extends Task>
- Parameters:
name
- The object's nametype
- The object's typeconfigurationAction
- The action to use to configure the object.- Returns:
- A
Provider
that will return the object when queried. The object may be created and configured at this point, if not already. - Throws:
UnknownTaskException
- Since:
- 5.0
-
-