Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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?

like image 649
Amir Ziarati Avatar asked Sep 28 '16 07:09

Amir Ziarati


People also ask

What is configuration in Gradle?

A “configuration” is a named grouping of dependencies. A Gradle build can have zero or more of them. A “repository” is a source of dependencies. Dependencies are often declared via identifying attributes, and given these attributes, Gradle knows how to find a dependency in a repository.

What are the 3 phases of the Gradle lifecycle?

Every Gradle build proceeds through three lifecycle phases in precisely the same order. These phases are initialization, configuration, and execution. During the initialization phase, Gradle starts up and locates the build files it must process.

What is default configuration in Gradle?

The default configuration extends from the runtime configuration, which means that it contains all the dependencies and artifacts of the runtime configuration, and potentially more. You can add dependencies and artifacts in the usual way (using a dependencies / artifacts block in B's build script).

What is afterEvaluate in Gradle?

The afterEvaluate is useful in the root gradle file of a multi project build when you want to configure specific items based on the configuration made in subprojects. Say you want to add a task for all subprojects that have a specific plugin defined.


1 Answers

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.

like image 90
Geralt_Encore Avatar answered Sep 18 '22 17:09

Geralt_Encore