https://kotlinlang.org logo
#gradle
Title
# gradle
r

Rodrigo Munera

10/23/2023, 4:47 PM
Is it possible to define a set of repositories as a variable in kotlin DSL to be reused downstream? Something like this is what I'd like to do:
Copy code
val repos: RepositoryHandler by configurations.creating {
  maven("mycompanyRepo")
  maventCentral()
}

buildscript {
  repositories = repos
}
v

Vampire

10/23/2023, 5:12 PM
Define a convention plugin that declares your repositories and then apply that convention plugin.
buildscript { ... }
repositories you should usually not use anyway. If you feel a need for them, it is most often better to create a custom task or plugin with the necessary logic to keep the actual buildscript more declarative.