How to Migrate build.gradle from Groovy to Kotlin DSL in Android Studio Bumblebee?

Viewed 346

I want to migrate build.gradle file from Groovy to Kotlin, since I updated my android studio to Bumblebee, I'm not sure how to do it.

This is how build.gradle looks when I create a new project.

I'm not sure on how to migrate plugins{} part.

buildscript {
    ext {
        compose_version = '1.0.1'
    }
}
plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
    id 'org.jetbrains.kotlin.jvm' version '1.6.21' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
1 Answers

I got the answer in the documentation here https://developer.android.com/studio/build#kts.

Here's how it's written in Kotlin.

plugins {
    id("com.android.application") version "7.1.0-beta02" apply false
    id("com.android.library") version "7.1.0-beta02" apply false
    id("org.jetbrains.kotlin.android") version "1.5.30" apply false
}

tasks.register("clean", Delete::class) {
    delete(rootProject.buildDir)
}
Related