In some of my Gradle based projects, i use libraries which have to be downloaded from many different Maven Repositories. To get a better overview of all used repos i wanted to group them in a list. Unfortunately it was a bit more complicated then i thought it would be. Because i couldn’t find other blog posts with my approach, i wanted to share it with you. So here is my solution:

This is how you add one repository to your buildscript:

When you want to add multiple repositories you have add a new maven{} block per URL, something like this :

and that:

doesn’t work.

The solution

First create a list in a Gradle(Groovy)

I created this method, which you have to add in the buildscript{} block:

Now you can use the method buildMaven() inside the repositories{} block inside a .each{} method of your repo list you want to add :