Use Kotlin to develop Gradle plug-ins in buildSrc mode

background

If you’re not familiar with Groovy + and use Kotlin, you don’t want to go back to Java

How

Copy the following code to the file buildSrc/build.gradle.

See project/build.gradle

Simply add buildSrcipt, the Kotlin plugin and the Kotlin dependency

buildscript {
    ext.kotlin_version = '1.4.31'

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: 'kotlin'

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

repositories {
    google()
    jcenter()
}
Copy the code