Gralde 的生命周期LifeCycle 和回调Hook

Gradle 生命周期 三大阶段 Three phases

1. Initialization 初始化

Gradle starts up and locates the build files it must process. Crucial during this phase is the determination of whether the build is single-project or multi-project. If it is a single project build, Gradle identifies a single build file to pass to the next phase. If it is a multi-project build, Gradle locates potentially many build files for processing in the next phase.

Notes:

此阶段 会确认项目中所有模块的静态配置文件及Gradle 构建脚本文件。

 

2. Configaration 配置

During configuration, Gradle executes each build file as a Groovy script. The effect of configuration is not the actual execution of build actions—that comes next—but rather the creation of a directed acyclic graph (DAG) of task objects.1 It is during the construction of this graph that many of the hook methods run.

Notes:

此阶段首先会加载项目中所有定义的task,包括单项目工程和多项目工程。 然后会从Gradle的执行命令开始, 根据task之间的依赖关系,从所有tasks 中找到一个构建所需要执行的有向无循环图 (DAG)。

注意, 有些插件Plugin在构建DAG的过程中,在Groovy 层面检查本地的依赖配置文件,否则会强制出错。例如华为的HMS 插件配置,所以自定义task配置HMS本地文件(agconnect-services.json)的hook时机只能在构建gradle graph 之前,和Evaluated 之后。

 

3. Execution

During this phase, Gradle identifies the tasks in the task DAG that must be executed, and executes them in dependency order.2 All build activities (e.g., compiling code, copying files, uploading artifacts, etc.) occur during execution. Some build hooks are evaluated during execution.

 

主要的生命周期回调

 

 

参考 Reference

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值