-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Gradle Effective Implementations Guide - Second Edition
By :
A project has one or more tasks to execute some actions, so a task is made up of actions. These actions are executed when the task is executed. Gradle supports several ways to add actions to our tasks. In this section, we discuss about the different ways to add actions to a task.
We can use the doFirst and doLast methods to add actions to our task, and we can use the left-shift operator (<<) as a synonym for the doLast method. With the doLast method or the left-shift operator (<<), we add actions at the end of the list of actions for the task. With the doFirst method, we can add actions to the beginning of the list of actions. The following script shows how we can use the several methods:
task first {
doFirst {
println 'Running first'
}
}
task second {
doLast { Task task ->
println "Running ${task.name}"
}
}
// Here we use the << operator
// as synonym for the doLast...
Change the font size
Change margin width
Change background colour