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

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

问题描述

我最近更改了 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 ?

究竟是什么配置阶段?

推荐答案

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

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:

  • 不,您不必手动触发配置.
  • 是的,如文档中所述,可能会出现问题.这功能应该非常适用于具有的多项目构建解耦项目.

在按需配置"模式下,项目配置如下:

In "configuration on demand" mode, projects are configured as follows:

  • 始终配置根项目.这样就支持典型的通用配置(所有项目或子项目脚本块).
  • 执行构建的目录下的项目也配置了,但是只在没有任何任务的情况下执行Gradle.这样,当按需配置项目时,默认任务的行为将正确无误.
  • 支持标准项目依赖并配置相关项目.如果项目 A 对项目 B 有编译依赖性,则构建 A 会导致两个项目的配置.
  • 支持通过任务路径声明的任务依赖,并导致相关项目的配置.示例:someTask.dependsOn(:someOtherProject:someOtherTask)
  • 从命令行(或工具 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.

这里是完整的文档.

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

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