Book Image

Mastering Gradle

Book Image

Mastering Gradle

Overview of this book

Table of Contents (17 chapters)
Mastering Gradle
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Task configuration


We discussed in first chapter that a build file consists of three phases: initialization, configuration, and execution, which are explained briefly as follows:

  • Initialization creates the project object.

  • The configuration phase configures the project object, creates DAG (Directed Acyclic Graph) based on task dependencies. It also executes the project and the task configuration statements.

  • The execution phase finally executes the actions mentioned in the task body.

The task API mainly defines two types of closures: doFirst(Closure closure) and doLast(Closure closure), which internally calls doFirst(Action action) and doLast(Action action). You can mention either one or both of them.

Tip

Statements mentioned outside of these actions are part of your configuration, which are executed during the configuration phase.

To verify the configuration phase of a task, you can execute the build script using the --dry-run or –m option. The --dry-run ( or –m) option only goes through the initialization...