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"
project.task("myTask")
Notice that in the later examples we had to pass the task name as a string. The task taskName
is a special form where we can use taskName
as a literal instead of string. This is done by Groovy AST transformation magic.
The project...