Search code examples
gradlekotlingradle-kotlin-dsl

Unable to use all configuration parameters with a custom configuration in gradle with kotlin-dsl


With gradle-groovy it is possible to have a custom configuration with a lot of parameters (group, name, version, ext, classifier):

configurations {
    explode
}

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

But I don't know how to do that with the kotlin-dsl. I tried:

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)
}

but without success. Any ideas?


Solution

  • It will work this way:

    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"
          )
        )
    }
    

    To be honest, for the sake of brevity, I'd rather go with string interpolation.

    Also, with groovy, a instance of Map is passed as well.