android-gradle-plugin - 仅向 Kotlin DSL 中的“免费”产品风格添加实现依赖项
问题描述
我正在将我们基于 Groovy 的脚本迁移到 Kotlin。除了不确定如何为特定风味添加依赖项外,我已经完成了大部分工作。到目前为止,这就是 Kotlin DSL 中的样子,但不确定为什么 freeImplementation("bar:2.2.8")
productFlavors {
create("free") {
...
...
}
create("paid") {
...
...
}
}
dependencies {
implementation("foo:1.2.0")
// This is not working when migrated to Kotlin DSL
freeImplementation("bar:2.2.8")
//Below was the code in Groovy which was working fine earlier
//freeImplementation "bar:2.2.8"
}
解决方案
下面是它的解决方案。
val freeImplementation by configurations
dependencies {
freeImplementation("bar:2.2.8")
}
或者,可以使用字符串文字来表示动态配置:
dependencies {
"freeImplementation"("bar:2.2.8")
}
推荐阅读
- c++ - 将一个字符连接成一个字符串
- selection - 选择语句教程
- python - 有没有办法检查某个值是否为 IN request.session.name?
- java - Java的JOptionsPane对话框窗口太小?
- firebase - Flutter - 在 Firebase 消息传递中获取数组
- python - 使用 sklearn 计算 NDCG 时出错
- python - skimage.morphology.skeletonize3d 的奇怪行为
- hive - 如何将合并查询转换为插入覆盖查询
- html - CSS background-position 无助于改变图像的位置
- ios - 使用 ADB2C 和 react-native-msal 登录时隐藏 iOS 中 WebViews 中显示的 url