23

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?

Geralt_Encore
  • 3,721
  • 2
  • 31
  • 46
Amir Ziarati
  • 14,248
  • 11
  • 47
  • 52

1 Answers1

26

This setting is relevant only for multiple modules projects. Basically, it tells Gradle to configure modules that only are 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.

aSemy
  • 5,485
  • 2
  • 25
  • 51
Geralt_Encore
  • 3,721
  • 2
  • 31
  • 46
  • 1
    thanks a lot for the link, why would Gradle configure all of them if it can go with just configuring related ones ? i mean why Gradle have not put this as default behavior ? if everything works fine in both ways and one of them is faster why its not the default behavior ? – Amir Ziarati Sep 28 '16 at 07:28
  • 1
    Probably it was easier to do it like this in a first place. "In the long term, this mode will become the default mode, possibly the only mode for Gradle build execution. " - from documentation. – Geralt_Encore Sep 28 '16 at 07:30