在构建生命周期中添加Gradle的钩子时? [英] When Gradle's hooks are added in build lifecycle?

查看:456
本文介绍了在构建生命周期中添加Gradle的钩子时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Gradle中有很多钩子。但我无法准确理解它们何时应用。
从文档中,我发现了构建和项目的钩子:


addListener(listener)
  • afterProject(闭包)
  • beforeProject(闭包)
  • buildFinished(闭包)

  • settingsEvaluated(closure)
  • taskGraph.whenReady

  • projectsLoaded



  • project.beforeEvaluate()



    所以我试图从书中的Gradle in Action( Muschko,Benjamin。建立生命周期。Gradle in Action。Np:np,2014. 100. Print。)可以更好地了解整个图片的时间和地点。 b

    所以当钩子被添加时,如果还有其他的构建,项目钩子?

    解决案

    看起来是正确的。 (我假设问题是回调被执行。) gradle.projectsLoaded 需要在初始化和配置阶段之间进行。 gradle.beforeProject 发生在配置阶段的某些点。在 Gradle构建语言参考中查看 Gradle 对于其他回调。

    In Gradle there are plenty of hooks. But I can't understand exactly when they are applied. From the docs I found hooks for the build and for a project:

  • addListener(listener)
  • afterProject(closure)
  • beforeProject(closure)
  • buildFinished(closure)
  • settingsEvaluated(closure)
  • taskGraph.whenReady
  • projectsLoaded
  • For project

  • project.afterEvaluate()
  • project.beforeEvaluate()
  • So I tried to make representation of figure from the book Gradle in Action (Muschko, Benjamin. "Hooking into the Build Lifecycle." Gradle in Action. N.p.: n.p., 2014. 100. Print.) to receive better idea for the whole picture when and where the hooks are apply?

    So when the hook are added and if there other build, project hooks?

    解决方案

    Looks about right. (I assume the question is when callbacks are executed.) gradle.projectsLoaded needs to go between initialization and configuration phase. gradle.beforeProject happens at certain points during the configuration phase. Check out Gradle in the Gradle Build Language Reference for other callbacks.

    这篇关于在构建生命周期中添加Gradle的钩子时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆