Be able to define logic to select an artifact download repository

At my company we have 3 maven repositories: releaeses, snapshots, thirdparty. This is a rather typical layout.

For performance and enforcement of rules, we’d like to be able to define for each artifact that is requested / downloaded, which of the repositories should be asked and in which order.

This would also enable to provide the maven style notion of snapshot / release only repositories.

Is there a chance to configure this already? If not, would this be hard to provide as API?

Dependencies are associated with configurations, configurations are associated with projects, and projects have a set of repositories. There is currently no way (that I know of) to define multiple sets of repositories in a project and have specific configurations resolve from them (in other words, there’s no per-configuration repositories).
Therefore, in one of our deployment tools, we resorted to using a multi-project build with special “repository subprojects”. Each of these special subprojects contains the different repository combinations and we assigned the dependencies to the appropriate subproject. These subprojects then get collected up for use by the root project.

Hi Chris,

this truly is a hack, isn’t it? It required to build all that dependency stuff around this (take care to put the dependency to the right project, etc.). And it has some problems (at least in my scenario) in case of transitive dependency resolution - snapshots in the snapshot repository do refer to released versions from the release repository. So when I do load the dependency from the snapshot configuration subproject, it is not possible to resolve to the released versions - because the release repository is not configured in that project.

What we do is resolve the first level dependencies (without transitive deps) via the special repo projects, then use the resolved versions in the root project to re-resolve the dependencies (with transitive deps). The root project configuration’s resolution strategy is setup to force the versions we got from the special projects.
The root project resolves from all the repositories supported by the special repo projects, so any transitive dependencies will resolve. This is based on the assumption that a given version of an artifact can be resolved from any of our repos and we’ll always get the same artifact, so we don’t need to worry about the second resolve grabbing from a different repo than the first resolve in the special repo projects.