Introducing
Your new presentation assistant.
Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.
Trending searches
Project is a representation of what needs to be built. For example, on Android the :app module is a Gradle project.
- Projects are registered in the settings.gradle file
- Most of the time, a project has a build.gradle file
A task is a representation of actions that need to be executed during the build process. For example, the compilation of Java code is started by a task.
Tasks are defined in the project build script and can have dependencies with each other.
Every Gradle build goes through 3 different lifecycle phases following the same order every time:
- The initialization phase
- The configuration phase
- The execution phase
In this phase, Gradle tries to identify all the projects involved in the build process.
Gradle looks at the settings.gradle file in order to identify the different projects.
At the end of the initialization phase, Gradle creates an instance of org.gradle.api.Project corresponding to each of these projects.
During this phase, Gradle executes the build script of each project identified in the previous phase. It does not mean that the Tasks in those build scripts are executed too. Instead, after evaluating those scripts as simple Groovy scripts and identify the tasks in it, Gradle builds a Directed Acyclic Graph (DAG) of task objects.
A DAG is a mathematical
algorithm for representing a graph. The “directed” term means each dependency arrow goes in one direction. “Acyclic” means that there are no loops in the graph.
Configuration on demand that gives the ability to configure only the relevant and necessary projects during the build process.
This is very useful in large Multi-project builds because it could considerably decrease build time.
During this phase, Gradle identifies the tasks that need to be executed based on the DAG of task objects created in the previous phase, and executes them according to their dependency order. All the build work and activities are actually done in this phase. For example: compiling source code and generating .class files, copying files, cleaning build directory, uploading archives, archiving files etc.