When Gradle's hooks are added in build lifecyc

2020-05-19 02:05发布

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?

    enter image description here

    1条回答
    ▲ chillily
    2楼-- · 2020-05-19 03:12

    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.

    查看更多
    登录 后发表回答