concept doLast in category gradle

appears as: doLast
Gradle in Action - corrected 9052019

This is an excerpt from Manning's book Gradle in Action - corrected 9052019.

Let’s set the lofty goal of creating the typical “Hello world!” example in Gradle. First you’ll create a file called build.gradle. Within that script, define a single atomic piece of work. In Gradle’s vocabulary, this is called a task. In this example, the task is called helloWorld. To print the message “Hello world!” make use of Gradle’s lingua franca, Groovy, by adding the println command to the task’s action doLast. The method println is Groovy’s shorter equivalent to Java’s System.out.println:

In chapter 2, I explained that the left shift operator (<<) is the shortcut version of the method doLast. Just to clarify: they do exactly the same thing. When executing the task with gradle printVersion, you should see the correct version number: