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

## org.gradle.api.execution
Interface TaskExecutionGraph

    interface TaskExecutionGraph

A `TaskExecutionGraph` is responsible for managing the execution of the Task instances which are part of the build. The `TaskExecutionGraph` maintains an execution plan of tasks to be executed (or which have been executed), and you can query this plan from your build file.

You can access the `TaskExecutionGraph` by calling org.gradle.api.invocation.Gradle#getTaskGraph(). In your build file you can use `gradle.taskGraph` to access it.

The `TaskExecutionGraph` is populated only after all the projects in the build have been evaulated. It is empty before then. You can receive a notification when the graph is populated, using #whenReady(groovy.lang.Closure) or #addTaskExecutionGraphListener(TaskExecutionGraphListener).

Method Summary
`void` | `addTaskExecutionGraphListener(TaskExecutionGraphListener listener)` Adds a listener to this graph, to be notified when this graph is ready.
`void` | `addTaskExecutionListener(TaskExecutionListener listener)` Adds a listener to this graph, to be notified as tasks are executed.
`void` | `afterTask(Closure closure)` Adds a closure to be called immediately after a task has executed.
`void` | `beforeTask(Closure closure)` Adds a closure to be called immediately before a task is executed.
`List` | `getAllTasks()` Returns the tasks which are included in the execution plan.
`boolean` | `hasTask(java.lang.String path)` Determines whether the given task is included in the execution plan.
`boolean` | `hasTask(Task task)` Determines whether the given task is included in the execution plan.
`void` | `removeTaskExecutionGraphListener(TaskExecutionGraphListener listener)` Remove a listener from this graph.
`void` | `removeTaskExecutionListener(TaskExecutionListener listener)` Remove a listener from this graph.
`void` | `whenReady(Closure closure)` Adds a closure to be called when this graph has been populated.

Method Detail

### addTaskExecutionGraphListener

    public void addTaskExecutionGraphListener(TaskExecutionGraphListener listener)

  Adds a listener to this graph, to be notified when this graph is ready.

  param:
    listener The listener to add. Does nothing if this listener has already been added.

### addTaskExecutionListener

    public void addTaskExecutionListener(TaskExecutionListener listener)

  Adds a listener to this graph, to be notified as tasks are executed.

  param:
    listener The listener to add. Does nothing if this listener has already been added.

### afterTask

    public void afterTask(Closure closure)

  Adds a closure to be called immediately after a task has executed. The task is passed to the closure as the first parameter. The task execution exception, if any, is passed as the second parameter. Both parameters are optional.

  param:
    closure The closure to execute when a task has been executed

### beforeTask

    public void beforeTask(Closure closure)

  Adds a closure to be called immediately before a task is executed. The task is passed to the closure as a parameter.

  param:
    closure The closure to execute when a task is about to be executed.

### getAllTasks

    public List getAllTasks()

  Returns the tasks which are included in the execution plan. The tasks are returned in the order that they will be executed.

  return:
    The tasks. Returns an empty set if no tasks are to be executed.
  throws:
    IllegalStateException When this graph has not been populated.

### hasTask

    public boolean hasTask(java.lang.String path)

  Determines whether the given task is included in the execution plan.

  param:
    path the absolute path of the task.
  return:
    true if a task with the given path is included in the execution plan.
  throws:
    IllegalStateException When this graph has not been populated.

### hasTask

    public boolean hasTask(Task task)

  Determines whether the given task is included in the execution plan.

  param:
    task the task
  return:
    true if the given task is included in the execution plan.
  throws:
    IllegalStateException When this graph has not been populated.

### removeTaskExecutionGraphListener

    public void removeTaskExecutionGraphListener(TaskExecutionGraphListener listener)

  Remove a listener from this graph.

  param:
    listener The listener to remove. Does nothing if this listener was never added to this graph.

### removeTaskExecutionListener

    public void removeTaskExecutionListener(TaskExecutionListener listener)

  Remove a listener from this graph.

  param:
    listener The listener to remove. Does nothing if this listener was never added to this graph.

### whenReady

    public void whenReady(Closure closure)

  Adds a closure to be called when this graph has been populated. This graph is passed to the closure as a parameter.

  param:
    closure The closure to execute when this graph has been populated.

Groovy Documentation