gradlekotlingradle-kotlin-dsl

How to add a maven repository by url using kotlinscript DSL (build.gradle.kts)


Whats the equivalent of the following code snippet from a build.gradle in a build.gradle.kts version?

repositories {
  mavenCentral()
  maven {
    url '<MAVEN REPO URL>'
  }
}

Solution

  • As an addition to the other answers, in #kotlin-dsl/256 shortcut methods were added to the various repository methods to do something like the following:

    repositories {
      mavenCentral()
      maven(url = "<MAVEN REPO URL>")
    }
    

    According to the issue, this was added in the Kotlin DSL version 0.11.1. The 0.11.x versions were included in the Gradle 4.2 release.

    To see the Gradle version you are running with your build when using the Gradle wrapper run ./gradlew --version.