I end up having to define my maven repository all over the place in my build.gradle
files. The definition can often be very cumbersome:
repositories {
jcenter()
maven {
url "https://mymavenurl/releases"
credentials(Credentials) {
username USERNAME
password PASSWORD
}
}
}
Notice above how gradle offers a nice way of defining commonly used maven repositories (i.e. jcenter()
). I'd like a way in a plugin or in a parent gradle script to define the repository in a function, or statically, and then just call it inside the repositories
block: myMavenRepo()
.
My knowledge of groovy is lacking, so I don't quite have the understanding I need to parse the groovy sources that I'm seeing to find a nice way to do this. How would I do this?
I'm aware that in a parent gradle file, I could use allProjects
or subProjects
. I don't want to add these maven repositories to all modules, but instead only specific ones.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…