是的,您可以在 Gradle Kotlin DSL 的父项目中设置 property,并在子项目中使用。

在父项目的 'settings.gradle.kts' 文件中,您可以设置一个 property,如下所示:

rootProject.name = "parent-project"

// 设置一个名为 myProperty 的 property
extra['myProperty'] = "value"

然后,在子项目的 'build.gradle.kts' 文件中,您可以通过 'rootProject' 对象来获取父项目的 property,如下所示:

// 获取父项目的 myProperty property
val myPropertyValue: String by rootProject.extra

// 在子项目中使用 myPropertyValue
println('myProperty value: $myPropertyValue')

这样,您就可以在父项目中设置 property,并在子项目中使用该 property。

Gradle Kotlin DSL 多项目结构:在父项目设置属性并在子项目中使用

原文地址: https://www.cveoy.top/t/topic/pdwH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录