Android Studio Hedgehog中potpourri模块的Gradle Kotlin等价写法
Groovy版Gradle转Kotlin版(针对potpourri模块)
1. 模块级build.gradle.kts中的依赖配置
对应的Kotlin语法依赖代码如下:
dependencies { implementation(files("libs/jsch-0.1.54.jar")) implementation(project(":potpourri")) }
2. settings.gradle.kts中的模块引入配置
对应的Kotlin语法代码如下:
include(":app") include(":potpourri") project(":potpourri").projectDir = File(settingsDir, "../Potpourri/app")
转换关键点
- Groovy中无需括号的函数调用,在Kotlin DSL里要显式添加括号
- Kotlin创建
File实例不用new关键字,直接调用构造方法即可 - 字符串用双引号即可,和Groovy用法一致
内容的提问来源于stack exchange,提问作者Kevin Gilbert
相关产品推荐
相关产品推荐

