gradle / kotlin-dsl-samples

Samples builds using the Gradle Kotlin DSL
https://gradle.org/kotlin/
Other
3.71k stars 434 forks source link

Add support for declaring collections of dependencies #1315

Closed magJ closed 5 years ago

magJ commented 5 years ago

Context

The gradle-dsl supports adding multiple dependencies at a time, using collections and varargs syntax. Thus when transitioning scripts from groovy to kotlin users are forced to adopt a much more verbose syntax.

https://github.com/gradle/kotlin-dsl/issues/639 https://github.com/gradle/kotlin-dsl/issues/1187 https://github.com/gradle/gradle/issues/7649

In #639 the determination was made that this functionality should be added upstream by adding to gradles DependencyHandler API, and thus the issue was migrated.

Not sure that I really agree with that assessment, even if a collection overload is eventually added to the gradle API, the kotlin-dsl will still need to provide specialized configuration accessors pointing to it.

Contributor Checklist

JLLeitschuh commented 5 years ago

Not sure that I really agree with that assessment, even if a collection overload is eventually added to the gradle API, the kotlin-dsl will still need to provide specialized configuration accessors pointing to it.

Can you elaborate?

magJ commented 5 years ago

Can you elaborate?

Well for example the kotlin-dsl adds functions like

fun DependencyHandler.create(
    group: String,
    name: String,
    version: String? = null,
    configuration: String? = null,
    classifier: String? = null,
    ext: String? = null
)

I would argue, that following the same logic, this function should be part of the gradle API itself.

If a Collection method was later added to the gradle API, the accessors implementation could just be switched to point to the new API(assuming the added API also has a void/Unit return type.)

eskatos commented 5 years ago

Closing alongside https://github.com/gradle/kotlin-dsl/issues/1371 See https://github.com/gradle/kotlin-dsl/issues/1371#issuecomment-486185728