Gradle executes a series of commands called task declared inside the build.gradle
file. The syntax to declare tasks is Groovy-based, as described before. A simple example of how to declare a task is:
task goGradle { doLast { println 'Gradle Task' } }
The command to execute this simple task is:
$ gradle goGradle
The output for this command is:
Gradle Task
Another syntax to define the same task is:
task goGradle << { println ''Gradle Task' }
In the first task definition, we use the doLast
block to wrap actions to perform; we can use other instructions such as doFirst
to decide task ordering. Thanks to doFirst
and doLast
, Gradle accomplishes its main characteristic to use a DAG for a task's order.
More Gradle functionalities are tasks, and they are executed with the command-line syntax explained.
If you want to know more about how Gradle's tasks work, you can consult the online manual at http://www.gradle.org/.