[英]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.