Externalized repository configuration

Hi,

we’re using a custom Gradle distribution, that just adds an init script to configure a base set of repositories (our own Nexus instance) to be used for all projects. It does something like

allprojects { project ->
    project.repositories {
        [...]
    }
    project.buildscript.repositories {
        [...]
    }
}

One problem of ours are settings scripts. We are also using plugins for some settings scripts, but there is no equivalent mechanism to define repositories there from the init stage.

As a workaround we do

gradle.ext.injectRepositories = { repositories ->
    repositories {
        [...]
    }
}

in the init script and then reference this custom method on the Gradle object from the settings script’s buildscript block to define the same repositories there.

This solution dates back to our Gradle 1.x days and is obviously not a pretty one. Is there a better way to define repositories for all relevant build stages from the init level with a newer Gradle version? Or is there at least a more elegant workaround than the one I described?

Best regards
Oli