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

↘锁芯ラ 提交于 2019-12-21 03:23:22

问题


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

回答1:


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.




回答2:


At 2018-01-13 the correct syntax is the following (instead of url, the function setUrl):

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


来源:https://stackoverflow.com/questions/48242437/how-to-add-a-maven-repository-by-url-using-kotlinscript-dsl-build-gradle-kts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!