官术网_书友最值得收藏!

Build life cycle

Gradle build has a life cycle, which consists of three phases: initialization, configuration, and execution. Understanding the build life cycle and the execution phases is crucial for Gradle developers. Gradle build is primarily a collection of tasks and a user can define the dependency between the tasks. So, even if two tasks depend on the same task, for example, Task C and Task B both depend on Task A, Gradle makes sure that Task A will execute only once throughout the execution of the build script.

Before executing any task, Gradle prepares a Directed Acyclic Graph (DAG) of all tasks for the build. It is directed because a task directly depends on another task. It is acyclic because, if Task A depends on Task B and if you make Task B depend on Task A, it will result in an error, as there can't be cyclic dependency between two tasks. Before executing the build script, Gradle configures the task dependency graph.

Let's quickly discuss the three build phases.

Initialization

User can create a build script for a single project as well as for a Multi-project build. During the initialization phase, Gradle determines which projects are going to take part in the build process, and creates a Project instance for each of these projects.

Configuration

This phase configures the project object. All the build scripts (in case the user is executing a multiproject build), which are part of the build process are executed without executing any task. This means whatever statements you have written outside of the task in the configuration block would be executed in the configuration phase. No tasks would be executed here; only the directed acyclic graph would be created for all tasks.

Execution

In this phase, Gradle executes all tasks as per the order given in the command line. However, if any dependencies exist between tasks, those relationships will be honored first before the command-line ordering.

主站蜘蛛池模板: 耒阳市| 黔东| 合山市| 泰安市| 八宿县| 淮滨县| 杨浦区| 宁安市| 综艺| 南靖县| 泽州县| 治多县| 精河县| 邵东县| 香港 | 景洪市| 施秉县| 剑川县| 金坛市| 察哈| 久治县| 汉川市| 崇文区| 时尚| 剑河县| 堆龙德庆县| 天祝| 宜州市| 沧源| 绥阳县| 二连浩特市| 鹤庆县| 堆龙德庆县| 西城区| 玛曲县| 牡丹江市| 建平县| 弥勒县| 城市| 鄱阳县| 修水县|