How to define a helper method for gradle repository?

Viewed 1104

Gradle scripts have shortcut functions to define common well known repositories, for example

repositories {
    mavenCentral()
}

I would like to define my own shortcut function something like myPrivateMavenRepo() so that I can write something like

repositories {
    mavenCentral()
    myPrivateMavenRepo()
}

Rather than

repositories {
    mavenCentral()
    maven {
        url "http://repo.mycompany.com/maven2"
    }
}

Questions:

  • How can a custom repo function be developed?
  • Where is this custom function hosted?
  • I have lots of repos that I want to switch to gradle I don't want to hardcode each build.gradle file with the repo Url how do I centralize this in a way that is easy to bootstrap?
2 Answers
Related