Task name abbreviation
Before we look at more Gradle command-line options, it is good to learn about a real timesaving feature of Gradle: task name abbreviation. With task name abbreviation, we don't have to type the complete task name on the command line. We only have to type enough of the name to make it unique within the build.
In our first build we only have one task, so the command gradle h
should work just fine. But then, we didn't take into account the built-in task help
. So, to uniquely identify our helloWorld
task, we use the abbreviation hello
:
hello-world $ gradle -q hello Hello world.
We can also abbreviate each word in a camel case task name. For example, our task name helloWorld
can be abbreviated to hW
:
hello-world $gradle -q hW HelloWorld
This feature saves us the time spent in typing the complete task name and can speed up the execution of our tasks.