What is on-demand configuration in Gradle?

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

I know that you can guess a lot from the words β€œon-demand configuration”, but I want to know the exact effect of this function? Do I have to do something to run the configuration if I set this argument to true ?

Can something go wrong if I set it to true ?

Which configuration exactly?

+5
source share
1 answer

This option applies only to projects with multiple modules. Basically, it tells Gradle to configure modules that apply only to requested tasks, and not to configure them all by default.

To more accurately answer your questions:

  • No, you do not need to run the setup manually.
  • Yes, something may go wrong as stated in the documentation. The function should work very well for multi-project builds that are untied projects.

In the "On-demand configuration" mode, projects are configured as follows:

  • The root project is always configured. Thus, a standard common configuration is supported (all projects or script subprojects).
  • The project in the directory in which the assembly is performed is also configured, but only when Gradle is executed without any tasks. Thus, default tasks behave correctly when projects are configured on demand.
  • Standard project dependencies are supported and related projects are configured. If project A has a dependency on compiling project B, then building A causes the configuration of both projects.
  • It supports task dependencies declared through the path to the task and cause the configuration of the corresponding projects. Example: someTask.dependsOn ( :someOtherProject:someOtherTask )
  • The task requested through the task path from the command line (or Tooling API) invokes the configuration of the corresponding project. For example, building projectA:projectB:someTask calls the projectB configuration.

Here is the full documentation.

+5
source

Source: https://habr.com/ru/post/1257373/


All Articles