无法使用kotlin-dsl在gradle中使用自定义配置的所有配置参数

时间:2017-09-25 11:27:20

标签: gradle kotlin 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.creating

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 :(得分:2)

它将以这种方式工作:

val explode by configurations.creating

dependencies {
    explode(mapOf(
      "group" to "org.apache.samza",
      "name" to "samza-shell",
      "ext" to "tgz",
      "classifier" to "dist",
      "version" to "0.13.1"
      )
    )
}

说实话,为了简洁起见,我宁愿选择字符串插值。

此外,使用groovy时,也会传递Map的实例。