如何使用Gradle Kotlin-dsl添加新配置

时间:2017-09-25 09:46:45

标签: gradle gradle-kotlin-dsl

使用gradle-groovy可以使用以下命令创建新配置:

configurations {
    explode
}

dependencies {
    explode (group: 'org.apache.samza', name: 'samza-shell', ext: 'tgz', classifier: 'dist', version: "$SAMZA_VERSION")
}

但我不知道如何用kotlin-dsl做到这一点。我试过了:

val explode by configurations

dependencies {
    explode(group = "org.apache.samza", name = "samza-shell",  ext = "tgz", classifier = "dist", version = samzaVersion)
    // "explode"(group = "org.apache.samza", name = "samza-shell",  ext = "tgz", classifier = "dist", version = samzaVersion)
}

但没有成功。有什么想法吗?

1 个答案:

答案 0 :(得分:4)

请你试试:

val explode by configurations.creating

或:

val explode = configurations.create("explode")

以下build.gradle.kts脚本可以正常运行:

repositories {
    mavenCentral()
}

val explode by configurations.creating

dependencies {
    explode("rg.apache.samza:samza-shell:0.13.1")
}