Amir Ziarati Amir Ziarati - 3 years ago 234
Android Question

what exactly is "configuration on demand" in Gradle?

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 file.

I know you can guess a lot from the word "configuration on demand", but i wanna know the exact impact of this feature ? do i have to do sth to trigger configuration here after if I pass this argument true ?

can something go wrong in any situation if i pass it true ?

what is configuration phase exactly ?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download