Current syntax to specify Maven repositories is not very idiomatic. Providing a regular Kotlin maven()function with parameters like maven(url: String, name: String? = null, ...) would be more easy to use for end users via autocomplete, positional or named parameters, and would read and write more easily.
Current syntax:
repositories {
maven { setUrl("...") }
}
````
Proposed syntax:
```kotlin
repositories {
maven(url = "...") // can be abbreviated to maven("...")
}
Alternatively we could add the strongly typed setter setUrl(URI) to MavenArtifactRepository and then the syntax would be:
maven { url = uri("...") }
As a second step we could work with the Kotlin team to introduce the concept of implicit conversion compiler plugins and achieve complete parity with Groovy with the advantage of compile time checking:
maven { url = "..." } // statically checked implicit conversion from String to URI
I like the alternative route a lot.
We should refrain from adding adhoc shortcuts. They are terrible to maintain, they may outnumber us at some point 馃槃 and they surely will minimize the goodness we could get from a coherent frontend on top of the Gradle API.
Type safe setters have been added to the Gradle API in:
MavenArtifactRepositoryIvyArtifactRepositoryMavenPluginRepositoryIvyPluginRepositorySee https://github.com/gradle/gradle/issues/1823
This provides the following:
repositories {
maven { url = uri("...") }
}
Implicit conversions will be addressed in https://github.com/gradle/gradle-script-kotlin/issues/335
As commented on gradle#335, I am against introducing implicit conversion to Kotlin, and I still think such shortcut is relevant for such frequently used statement.
We should reconsider this shortcut.
Most helpful comment
We should reconsider this shortcut.