Best way to externally configure maven repository once for 3 different uses?


(Doug Lethin) #1

[Sorry if this is a repeat. I thought I saw this topic once, but now that I’m ready to implement it I can’t find it again.]

We use a nexus repository in my organization. I need to specify that URL in 3 different locations for all of my independent gradle builds:

  1. The buildscript/repositories section for access to plugins within the build 2. To define the repository to use for my project dependencies 3. The repository to use for the maven-publish-plugin.

[Note that for #3, The repository URL is not actually the same. We use nexus group repositories for #1 and #2, and for #3, we publish to a nexus hosted repository that is included in group repository used above.]

I would like to do this similarly to maven. In maven’s case you can do this externally in a settings.xml file.

I need to do this externally so if the repository location ever changes (which it will be actually at the end of the month – case in point), I don’t have to update every projects build.

In fact, we’re already using the maven-publish-auth plugin to extract the credentials for publishing to our repo out of settings.xml, so any solution that allows me to perhaps just point to settings.xml for all my above repo definitions would be nice to for consistency.

My understanding is that the tricky part about is #1 since apparently you can’t specify the buildscript section in an init script.

One last requirement is that I would like to make sure I can do offline builds (minus publishing of course), so I want to make sure all external dependencies are cached. Because of this, I prefer a solution that doesn’t include ‘apply from (URL)’.

Thanks.

Doug