what exactly is “configuration on demand” in Gradle?

大憨熊 提交于 2019-12-01 14:33:05

问题


I recently changed some settings in Gradle to speed up its process and one of them was changing this: org.gradle.configureondemand=true property in gradle.properties file.

I know you can guess a lot from the words "configuration on demand", but I wanna know the exact impact of this feature? Do I have to do something to trigger configuration if I set this argument as true?

Can something go wrong if I set it as true ?

What configuration phase exactly is?


回答1:


This setting is relevant only for multiple modules projects. Basically, it tells Gradle to configure modules that only relevant to the requested tasks instead of configuring all of them, which is a default behaviour.

To answer more precisely to your questions:

  • No, you don't have to trigger configuration manually.
  • Yes, something could go wrong as stated in the documentation. The feature should work very well for multi-project builds that have decoupled projects.

In “configuration on demand” mode, projects are configured as follows:

  • The root project is always configured. This way the typical common configuration is supported (allprojects or subprojects script blocks).
  • The project in the directory where the build is executed is also configured, but only when Gradle is executed without any tasks. This way the default tasks behave correctly when projects are configured on demand.
  • The standard project dependencies are supported and makes relevant projects configured. If project A has a compile dependency on project B then building A causes configuration of both projects.
  • The task dependencies declared via task path are supported and cause relevant projects to be configured. Example: someTask.dependsOn(:someOtherProject:someOtherTask)
  • A task requested via task path from the command line (or Tooling API) causes the relevant project to be configured. For example, building projectA:projectB:someTask causes configuration of projectB.

Here is the full documentation.



来源:https://stackoverflow.com/questions/39740440/what-exactly-is-configuration-on-demand-in-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!