Task Types & Actions
Explore different task types, define task actions, and manage task inputs and outputs.
Tasks: Types & Actions Intro
In Gradle, tasks are the core units of work. While Lesson 1 showed how to define basic tasks, this lesson dives deeper into task types and actions.
We'll learn how different task types offer specific functionalities, define what a task actually does using actions, and understand how to manage task inputs and outputs for efficient builds.
What are Task Actions?
A task action is a piece of code that a task executes. Think of it as the 'what to do' part of your task.
You can define actions directly within a task block or using special methods like doLast and doFirst.
- Directly: Code inside
doLast { ... }or the task block itself. doLast: Executes the action at the very end of the task's execution.doFirst: Executes the action at the very beginning of the task's execution.