Gradle - 属性可以放在 settings.gradle.kts 中吗
Gradle - Can properties be placed in a settings.gradle.kts
是否可以将我目前在 gradle.properties
中的这些设置放入我的 settings.gradle.kts
文件中?
org.gradle.parallel=true
org.gradle.caching=true
谢谢
不,这是不可能的,因为 gradle.properties
配置运行 Gradle 构建的 JVM,而 settings.gradle.kts
在 JVM 启动和构建启动后配置项目。见 documentation on the build environment
根据我的经验,你做不到。
您可以检查 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
in GRADLE_USER_HOME directory.
system properties, e.g. when -Dgradle.user.home
is set on the command line.
这些属性用于为您的构建设置环境:
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)
您也可以将相同的规则应用于 settings.gradle
和 settings.gradle.kts
。In the documentation:
Gradle defines a settings file. The settings file is determined by Gradle via a naming convention. The default name for this file is settings.gradle
.
The settings file is executed during the initialization phase.
中的 Settings
class
There is a one-to-one correspondence between a Settings instance and a settings.gradle
settings file.
您可以检查可以使用此文件初始化的属性。
是否可以将我目前在 gradle.properties
中的这些设置放入我的 settings.gradle.kts
文件中?
org.gradle.parallel=true
org.gradle.caching=true
谢谢
不,这是不可能的,因为 gradle.properties
配置运行 Gradle 构建的 JVM,而 settings.gradle.kts
在 JVM 启动和构建启动后配置项目。见 documentation on the build environment
根据我的经验,你做不到。
您可以检查 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
in GRADLE_USER_HOME directory.system properties, e.g. when
-Dgradle.user.home
is set on the command line.
这些属性用于为您的构建设置环境:
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)
您也可以将相同的规则应用于 settings.gradle
和 settings.gradle.kts
。In the documentation:
中的Gradle defines a settings file. The settings file is determined by Gradle via a naming convention. The default name for this file is
settings.gradle
. The settings file is executed during the initialization phase.
Settings
class
There is a one-to-one correspondence between a Settings instance and a
settings.gradle
settings file.
您可以检查可以使用此文件初始化的属性。