smauel
smauel

Reputation: 695

Nexus group ordering

We are using nexus as a repository management system. However we are encountering a problem in regards to managing our groups.

Basically we have an snapshot versioned artifact that lives in two repositories. We add both these repositories to the same group in the order that we would like nexus to search them. This is in accordance with the documentation: http://www.sonatype.com/books/nexus-book/reference/config-sect-managing-groups.html

group
    ...
    --> repo1
            ...
            --> com.test.example-1.0.0-SNAPSHOT
            ...
    --> repo2
            ...
            --> com.test.example-1.0.0-SNAPSHOT         
            ...
    ...

So by ordering repo1 above repo2 we always want to download the example artifact from repo1. What we find in reality however is that despite the ordering, we always download the latest snapshot version from either repo. So if repo2 has a more recent snapshot version we are pulling it down.

Has anyone else seen this behaviour? Does nexus not take ordering into account with snapshot repositories?

Upvotes: 0

Views: 1516

Answers (1)

Tamas Cservenak
Tamas Cservenak

Reputation: 751

This is actually not Nexus but Maven that does it, what happens:

  • Maven requests "maven-metatadata.xml" from Nexus
  • Nexus cycles over member repositories in given order (repo1, repo2...) and merges that XML files.
  • From merged XML, Maven "gets the knowledge" of the latest snapshot, and explicitly asks for it.
  • Nexus can't do anything, I bet your snapshots has different names (artifactId-1.0-yyyy.mm.dd.hh.mm.jar, but those two has probably different yyymmdd etc), and serves up what Maven asks

What you can do here to make Nexus "hide" stuff from Maven is Routing rules. Add a rule that for given groupId, or artifactId or whatever (it's actually a regexp) serve only from repo1.

Upvotes: 2

Related Questions