Tasks

As we have seen so far, a task is a named action that performs some build logic. It's a unit of build work. For example, clean, compile, dist, and so on, are typical build tasks that easily come to our mind if we have to write tasks for our project. Tasks are more or less analogous to Ant's targets.

The simplest way to create a task is as follows:

task someTask

Before we go any further with tasks, let's take a moment to ponder about task creation.

We used the taskName task form of a statement.

If we rewrite it as a task (taskName), it will immediately look like the method call.

The preceding method, as we might have already guessed by now, is available on the project object.

So, we could write one of the following as well:

  • project.task "myTask" ...

Get Gradle Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.