How can I list all the repositories available to the project's buildscript?
I'm migrating some projects from very simple Gradle builds to start using some custom platforms and convention plugins but I'm having some trouble importing some of those artifacts into the buildscript.
I've read this question and tried the following:
tasks.register("listrepos") {
doLast {
println("Repositories:")
project.buildscript.repositories.map { it as MavenArtifactRepository }
.forEach { println("Name: ${it.name}; url: ${it.url}") }
}
}
But the list is always empty.
It's awkward because I was expecting at least the gradlePluginPortal()
repository to be listed here.
EDIT:
After @PrasadU's answer I added the following snipped to my build.gradle.kts
file. I just updated it to the Kotlin DSL syntax:
project.afterEvaluate {
println("Running project afterEvaluate")
project.buildscript.repositories.asMap.forEach { (name, repo) ->
println("$name >> ${repo.name}")
}
}
The problem is that project.buildscript.repositories.asMap
is empty.