“按需配置"到底是什么?在Gradle中? [英] what exactly is "configuration on demand" in Gradle?

查看:72
本文介绍了“按需配置"到底是什么?在Gradle中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更改了Gradle中的某些设置以加快其处理速度,其中之一是更改此设置:gradle.properties文件中的org.gradle.configureondemand=true属性.

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.

我知道您可以从按需配置"一词中猜测很多,但是我想知道此功能的确切影响吗?如果将此参数设置为true,是否需要做一些事情来触发配置?

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?

如果将其设置为true会出问题吗?

Can something go wrong if I set it as true ?

确切的配置阶段是什么?

What configuration phase exactly is?

推荐答案

此设置仅与多个模块项目相关.基本上,它告诉Gradle配置仅与所请求任务相关的模块,而不是配置所有模块,这是默认行为.

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:

  • 始终配置根项目.这样,就可以支持典型的通用配置(所有项目或子项目脚本块).
  • 还配置了执行构建的目录中的项目,但仅当执行Gradle而没有任何任务时才进行配置.这样,当按需配置项目时,默认任务可以正常运行.
  • 支持标准项目依赖项,并配置了相关项目.如果项目A对项目B具有编译依赖性,则构建A会导致两个项目都被配置.
  • 支持通过任务路径声明的任务依赖性,并导致配置相关项目.示例:someTask.dependsOn(:someOtherProject:someOtherTask)
  • 通过任务路径从命令行(或Tooling API)请求的任务会导致相关项目的配置.例如,构建projectA:projectB:someTask会导致对projectB的配置.
  • 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.

此处是完整的文档.

这篇关于“按需配置"到底是什么?在Gradle中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆