tags:

views:

74

answers:

2

I have set up a Maven 2 repository (call 'dev repository') using Apache Archiva which holds artifacts of my private projects.

If I build an artifact of my own project, say group1:cat for example, and Cat depends on { group1:dog, commons:collection }. The group1:cat and group1:dog are sit in dev repository, and commons:collection in the Central.

Now, when I build group1:cat, maven will fetch group1:dog and commons:collection, the problem is maven will always search in both dev repository and central repository to find the dependencies, but what I want is it search group1:dog in dev repositories only, and search commons:collection in central repositories only. I have central mirrors say central-mirror1 and central-mirror2, so how to configure maven so it will search commons:collection in default central repository and central-mirror-1,2 etc., and won't bother my dev repositories at all?

+1  A: 

My setup uses my local Archiva instance to proxy central (and other 3rd party repositories). In my super pom, I've changed my repositories to only point to my local Archiva, and not search central at all. Everything comes in via my local proxy.

It's not quite what you're asking for, but I think it's an appropriate setup.

You can then use Archiva's black/white lists to tell it where to search for things.

Cogsy
+1  A: 

(...) what I want is it search group1:dog in dev repositories only, and search commons:collection in central repositories only.

I don't know how to achieve this and I don't think it's possible. How could maven be aware of the "source" repository for a given artifact?

But actually, why don't you make everything go through Archiva? What's the point of not using Archiva for all requests? If you don't want maven to check both repositories for your dependencies, it seems to be a pretty obvious solution. Moreover, people usually don't want to rely directly on central in a corporate environment (e.g. if it goes down you can't work anymore). No, really, I don't get it.

So, I'd just declare Archiva as a mirrorOf all repositories, like this:

<settings>
  ...
  <mirrors>
    <mirror>
      <id>internal-repository</id>
      <name>Maven Repository Manager running on repo.mycompany.com</name>
      <url>http://repo.mycompany.com/proxy&lt;/url&gt;
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>
Pascal Thivent