Externalizing Maven repos (settings.xml)


(Davor Sauer) #1

Is there a way to tell Gradle to use Maven repositories configured in settings.xml.

E.g. in our projects we uses mavenCentral(), but also we have couple of Maven repositories internally on Artifactory.
And it will be nice that this configuration can stay outside projects, e.g. mavenSettings().
And that settings xml contains list of internal repos, and user credentials.

Or is there some plugin for that? Because I could find something like this.


(Pierre) #2

Hi Davor,

Provided that your maven settings file defines mirrors, the following plugin should match your needs: https://github.com/mark-vieira/gradle-maven-settings-plugin

Regards,


(Davor Sauer) #3

Hi,

I saw/used that plugin, but then you need to specify repo id and url. And our current maven project don’t have that in pom.xml. It’s all in settings.xml

I’ll try to check maybe to make pull request to provide mavenLocalSetting() which will refer to all the repos in setting.xml.

Thx. for reminder!


(Stefan Oehme) #4

I think the answer is two-fold: The repos should be defined in the build, since they are part of the build’s definition. The build won’t work without them, so it shouldn’t be up to the user to add them. You can of course extract that into a plugin so you can apply it using a one-liner instead of repeating it in every build. The user credentials can be provided in ~/.gradle/gradle.properties.


(Davor Sauer) #5

Unfortunately we have a mixture of legacy projects on Maven and some new projects with Gradle.
Maven projects are relying on settings.xml to get the list of in company Maven repos and necessary credentials.

So I’m looking for something similar in Gradle world, without forcing developers to maintain settings.xml and gradle.properties at the same time.

Or maybe to tackle this problem from different angle. What if I want to introduce new private repository, but I don’t want to change my 20 or more projects by adding one more extra repo. Would be much easier to add that one repo to the settings.xml

Or maybe should I think about different approach and not to stick so much to the Maven concepts?


(Stefan Oehme) #6

The repo list can be a plugin, you don’t need to maintain it in every build. That being said, reading them from Maven settings.xml is also just a simple plugin away :slight_smile: Whichever way works better for you right now.