gradle 任务类型如何在 Kotlin/ 中定义

How is a gradle task type defined in Kotlin/

groovy 语句的 kotlin 等价物是什么

build.gradle

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

在build.gradle.kts

试试这个:

tasks.register("clean").configure {
    delete(rootProject.buildDir)
}