[英]Declaring flavor dependencies in multi-module project using gradle DSL
[英]Trouble converting multi-module gradle script to kotlin dsl
考虑一个简单的多模块 Android 项目设置,类似于:
app
common
其中app
模块和common
模块都需要实现一些共享的gradle逻辑,即:
android {
testOptions {
unitTests {
returnDefaultValues = true
}
animationsDisabled = true
}
lint {
abortOnError = false
}
}
当我使用 groovy dsl 指定上述逻辑,然后使用apply from: rootProject.file('common.gradle')
项目工作正常。 但是当我使用 kotlin dsl 包含指定上述逻辑时,我收到以下错误:
Unresolved reference: android
Unresolved reference: testOptions
Unresolved reference: unitTests
...
请注意,groovy 与 kotlin dsl 版本完全相同。 只需将文件扩展名更改为.kts
就会破坏构建。
我在这里做错了吗? 或者这是一个已知问题/限制?
Since Kotlin DSL requires compilation you cant use android {}
block in kts files like you did using Groovy because AGP is not available for kts files except build.gradle.kts
从 build.gradle.kts 中分离一些逻辑的唯一选项是约定插件或常规 gradle 插件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.