创建一个kotlin语言的android项目,项目的根目录下的build.gradle中会自动添加:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
如:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.72"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
在android项目里kotlin现阶段还是寄生在jvm平台的,所有的kotlin源代码都会被编译成class文件,这个编译过程依赖kotlin-gradle-plugin插件。