How to fully externalize repository urls

Coming from Maven in an Enterprise environment - our Maven builds always fully externalized references to our Nexus repositories. I’m not sure how best to pull out all repository references in a Gradle build so that those references come from the build environment. Any help is appreciated. --Ron

How are you doing this now with Maven? Are your builds inheriting repository information from a parent POM or is this information located in a local settings.xml?

In settings.xml. In Jenkins CI builds Jenkins can supply a settings.xml and it uses a mvn command line arg to override the default location to pick up the supplied settings.xml

It just so happens I am currently working on a plugin for reading configuration for Maven settings.xml files. Currently it just works with ‘&ltmirror&gt’ definitions but I am working on reading repository configuration defined in ‘&ltprofile&gt’ elements as well. How exactly is your enterprise repository defined in the settings file?

That might be enough. I’ll elaborate on our topology (possibly atypical)

Our Nexus repos sit behind a firewall in our customer development networks. For security reasons these networks don’t run DNS. So when I work from my desktop the IP address of the Nexus repos are different than when seen on Jenkins (also inside the customer development network).

As such we want the configuration of the repos to reside in the environment we’re building in (I.E my laptop and the CI server - each different).

So thanks for working on a plugin - it’s really appreciated. Trick is - that first line - To use this plugin…you reference jcenter. If I attempted to use it in our customer network - would grade try to resolve a DNS address or an IP address for jcenter? If the former a clean build would fail. I need all Maven resolution to go through my Nexus gateway residing in our customer networks.

Our mirror setups all have a final mirror entry that have a wildcard to ensure everything ultimately goes through our customer network Nexus gateways (which in turn hit our corporate proxies - the only allowed route out of the network - and there’s no DNS :slight_smile: ).

Not sure how the build-in maven central and jcenter resolution is actually implemented. If there was a way to tell Gradle that maven central and jcenter was somewhere else and a way for Nexus to act as a proxy - well, that would be dandy.


Yes, that becomes problematic, I’m working on getting the plugin on the Gradle plugin portal but I don’t think that will help you if you don’t have DNS on your internal network. You could upload the plugin to your internal Nexus repo but you would still have to register that repo with your build script somehow, sort of going back to your original post. One way to centralize that could be with an init script, possible packaged in a custom gradle distribution.