简体   繁体   English

Gradle - 属性可以放在 settings.gradle.kts 中吗

[英]Gradle - Can properties be placed in a settings.gradle.kts

Is it possible to place these settings which I currently have in gradle.properties in my settings.gradle.kts file?是否可以将我目前在gradle.properties中的这些设置放在我的settings.gradle.kts文件中?

org.gradle.parallel=true
org.gradle.caching=true

Thanks谢谢

No, this is not possible since gradle.properties configures the JVM that runs the Gradle build and settings.gradle.kts configures the project once the JVM has started and the build starts up.不,这是不可能的,因为gradle.properties配置运行 Gradle 构建的 JVM,并且settings.gradle.kts在 JVM 启动和构建启动后配置项目。 See the documentation on the build environment请参阅有关构建环境文档

In my experience you can't do it.根据我的经验,你不能这样做。

You can check the gradle properties in the official doc .您可以在官方文档中查看 gradle 属性。

The configuration is applied in following order (if an option is configured in multiple locations the last one wins):配置按以下顺序应用(如果在多个位置配置了一个选项,则最后一个获胜):

  • gradle.properties in project root directory.项目根目录中的gradle.properties

  • gradle.properties in GRADLE_USER_HOME directory. gradle.properties在 GRADLE_USER_HOME 目录中。

  • system properties, eg when -Dgradle.user.home is set on the command line.系统属性,例如在命令行上设置-Dgradle.user.home时。

These properties are used to sep up the environment for your build:这些属性用于为您的构建设置环境:

org.gradle.caching=(true,false)
org.gradle.caching.debug=(true,false)
org.gradle.configureondemand=(true,false)
org.gradle.console=(auto,plain,rich,verbose)
org.gradle.daemon=(true,false)
org.gradle.daemon.idletimeout=(# of idle millis)
org.gradle.debug=(true,false)
org.gradle.java.home=(path to JDK home)
org.gradle.jvmargs=(JVM arguments)
org.gradle.logging.level=(quiet,warn,lifecycle,info,debug)
org.gradle.parallel=(true,false)
org.gradle.warning.mode=(all,none,summary)
org.gradle.workers.max=(max # of worker processes)
org.gradle.priority=(low,normal)

Also you can apply the same rules to settings.gradle and settings.gradle.kts .您也可以将相同的规则应用于settings.gradlesettings.gradle.kts In the documentation : 在文档中

Gradle defines a settings file. Gradle 定义了一个设置文件。 The settings file is determined by Gradle via a naming convention.设置文件由 Gradle 通过命名约定确定。 The default name for this file is settings.gradle .此文件的默认名称是settings.gradle The settings file is executed during the initialization phase .设置文件在初始化阶段执行。

And looking at the Settings class in the API documentation并查看API 文档中的Settings

There is a one-to-one correspondence between a Settings instance and a settings.gradle settings file. Settings 实例和settings.gradle设置文件是一一对应的。

You can check the properties that you can initialize with this file.您可以检查可以使用此文件初始化的属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gradle 6 settings.gradle.kts 属性问题 - Gradle 6 settings.gradle.kts properties problem 在 settings.gradle.kts 中读取 Gradle 属性 - Reading Gradle properties in settings.gradle.kts 如何定义 settings.gradle.kts 和 build.gradle.kts 中可用的 kotlin dsl gradle 属性? - How to define kotlin dsl gradle properties available in settings.gradle.kts and build.gradle.kts? Gradle 6 迁移 settings.gradle.kts - Gradle 6 migration settings.gradle.kts settings.gradle.kts 的用途是什么? - What is the purpose of settings.gradle.kts? Gradle:在 settings.gradle.kts 和 buildSrc/build.gradle.kts 之间共享存储库配置 - Gradle: share repository configuration between settings.gradle.kts and buildSrc/build.gradle.kts 如何在 buildSrc/build.gradle.kts、settings.gradle.kts 和 build.gradle.kts 中导入辅助类? - How to import a helper class in buildSrc/build.gradle.kts, settings.gradle.kts, and build.gradle.kts? 使用Gradle Kotlin DSL在settings.gradle.kts中设置gradle.ext - Set gradle.ext in settings.gradle.kts with Gradle Kotlin DSL 有没有办法定义要在 gradle 6.0 的 settings.gradle.kts 和项目/子项目 build.gradle.kts 中使用的属性? - Is there a way to define property to be used in both settings.gradle.kts and projects/subprojects build.gradle.kts with gradle 6.0? 在 `settings.gradle.kts` 中使用 `dependencyResolutionManagement` 时,如何在 `gradle.build.kts` 中配置自定义 maven 依赖项? - How does one configure custom maven dependency in `gradle.build.kts` while using `dependencyResolutionManagement` in `settings.gradle.kts`?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM