Gradle Task: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 50: Line 50:
=Custom Tasks=
=Custom Tasks=
{{Internal|Extending Gradle with Custom Tasks|Extending Gradle with Custom Tasks}}
{{Internal|Extending Gradle with Custom Tasks|Extending Gradle with Custom Tasks}}
=Built-in Tasks=
Each build exposes a set of built-in tasks, that can be used right away without any additional configuration or loading any plugin:
* [[Gradle init Task|init]]
* [[Gradle wrapper Task|wrapper]]
* [[Gradle buildEnvironment Task|buildEnvironment]]
* [[Gradle components Task|components]]
* [[Gradle dependencies Task|dependencies]]
* [[Gradle dependencyInsight Task|dependencyInsight]]
* [[Gradle dependentComponents Task|dependentComponents]]
* [[Gradle help Task|help]]
* [[Gradle model Task|model]]
* [[Gradle projects Task|projects]]
* [[Gradle properties Task|properties]]
* [[Gradle tasks Task|tasks]]


=TO DEPLETE=
=TO DEPLETE=
{{Internal|Gradle Task TODEPLETE|Gradle Task TODEPLETE}}
{{Internal|Gradle Task TODEPLETE|Gradle Task TODEPLETE}}

Revision as of 22:46, 3 October 2020

Internal

Overview

A task represents a well defined piece of work that is executing during a build, such as compiling Java classes or creating a distribution file.


A tasks belongs to a project.

Task API

org.gradle.api.Task

Task DSL

Task

Task Structure

Tasks are instances implementing org.gradle.api.Task interface. Most tasks extend org.gradle.api.DefaultTask.


Task Name

Each task has a name, which is unique within the context of its owning project. The name must not contain dashes.

Task Path

A task path is the concatenation of the task owning project name and the task name, separated by the ":" character.

Declaring a Task

With DSL

Programmatically

Overview

With no plugins, a build has a small set of built-in tasks.

Each plugin typically adds more.

Custom tasks can be added in build.gradle or script plugins.

Task Configuration Closure

Task Action

Task Action Closure

Task action closures can be used to define custom simple tasks, in-line in build.gradle or in a script plugin.

@TaskAction

Task Dependency

Custom Tasks

Extending Gradle with Custom Tasks

Built-in Tasks

Each build exposes a set of built-in tasks, that can be used right away without any additional configuration or loading any plugin:

TO DEPLETE

Gradle Task TODEPLETE