-
Book Overview & Buying
-
Table Of Contents
Gradle Effective Implementations Guide - Second Edition
By :
Until now, we have defined tasks independent of each other. However, in our projects, we need dependencies between tasks. For example, a task to package compiled class files is dependent on the task to compile the class files. The build system should then run the compile task first, and when the task is finished, the package task must be executed.
In Gradle, we can add task dependencies with the dependsOn method for a task. We can specify a task name as the String value or task object as the argument. We can even specify more than one task name or object to specify multiple task dependencies. First, let's look at a simple task dependency:
task first << { task ->
println "Run ${task.name}"
}
task second << { task ->
println "Run ${task.name}"
}
// Define dependency of task second on task first
second.dependsOn 'first'
Note that we define the dependency of the second task on the...
Change the font size
Change margin width
Change background colour