When I rename a build.gradle of an existing project to build.gradle.kts, there is a leap of faith, a moment where the IDE is useless, where I need to reach as fast as possible the point where ./gradlew tasks succeeds.
In this context, the repositories configuration gets in the way for dumb reasons.
Ideally, that syntax would work in both groovy and kotlin
repositories {
mavenCentral()
maven { url "https://example.com" } }
}
maven { url "https://example.com" } } does not workmaven { url = "https://example.com" } } does not work eitherThis has bad side effects: if you have a buildscript blog, the plugins won't get resolvec, etc..
The current "solution" is maven { setUrl("https://example.com") } }, which
mavenCentral() and friendsMake this a valid syntax (see first comment)
repositories {
maven("https://example.com")
}
See intro
IntelliJ or Android Studio
Here is a sample implementation for
repositories {
maven("https://example.com")
}
fun RepositoryHandler.maven(
url: String,
name: String? = null,
username: String? = null,
password: String? = null,
configureIvy: Action<in IvyArtifactRepository>? = null
) {
this.maven {
setUrl(url)
if (name != null) setName(name)
if (username != null && password != null) {
credentials {
setUsername(username)
setPassword(password)
}
}
if (configureIvy != null) ivy(configureIvy)
}
}
There is already the ~syntax~ extension you request...
See
https://github.com/gradle/kotlin-dsl/blob/5aedaa700036f9c354aa8a944e98568c1e923ee0/subprojects/provider/src/main/kotlin/org/gradle/kotlin/dsl/RepositoryHandlerExtensions.kt#L23-L56
Oh nice!
Most helpful comment
There is already the ~syntax~ extension you request...
See
https://github.com/gradle/kotlin-dsl/blob/5aedaa700036f9c354aa8a944e98568c1e923ee0/subprojects/provider/src/main/kotlin/org/gradle/kotlin/dsl/RepositoryHandlerExtensions.kt#L23-L56