How to list the configured repositories?

前端 未结 3 1221
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-01 13:33

How can I list all the repositories configured for a project?

Background: I have a pretty complex gradle build script and cannot get my NetBeans to download the sour

3条回答
  •  礼貌的吻别
    2021-01-01 14:04

    If someone comes to this page looking for the Kotlin (build.gradle.kts) equivalent of @Alberto's answer, it would be done as follows:

    tasks.register("listrepos") {
        doLast {
            println("Repositories:")
            project.repositories.map{it as MavenArtifactRepository}
                .forEach{
                println("Name: ${it.name}; url: ${it.url}")
            }
        }
    }
    

    Just as a heads up, the cast to a MavenArtifactRepository is required in the Kotlin version to get the url property. This could be different for you if you are not adding Maven Repositories.

提交回复
热议问题