tags:

views:

1048

answers:

4

Hi,

does anyone knows how do I specify in Ivy something like mirror/mirrorOf in Maven? I'm working with a local Maven proxy (Nexus) and need the tool to specify which of the parent repositories should Nexus proxy be accessing.

In Maven I do simply:

<mirrors>
  <mirror>
    <id>central-mirror</id>
    <mirrorOf>central</mirrorOf>
    <url>http://localhost:8081/content/repositories/central&lt;/url&gt;
  </mirror>
</mirrors>

but I can't find this kind of option in Ivy.

+1  A: 

I don't think such an option exists directly. You could try implementing a chain, and put your Nexus repository ahead of central in that chain. If I understand how chains work correctly (that's a big if), Ivy will check your repository before central, so as long as your repository has the relevant contents central won't be needed.

See the tutorial for details.

Rich Seller
Thanks - that's what I've been afraid of. Ivy just doesn't live to my expectations after working with Maven.
Matthias Hryniszak
Ivy just has a different way of approaching dependency management.
Mark O'Connor
A: 

I have done the same but with Archiva, what is very similar. You only have to declare in a new chain the following:

<chain name="private">
<url name="archiva" m2compatible="true">
  <ivy pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/ivy.xml" /> 
  <artifact pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> 
  <artifact pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/[artifact].[ext]" /> 
  </url>
</chain>
David García González
Using Archiva to achieve proxying is not in the scope of the question. You can do that in a number different ways. The problem is to use that from ivy in a similar way it's used in maven.
Matthias Hryniszak
I don't think such an option exists in Ivy.
David García González
A: 

Archiva manages Maven 2 repositories (artifacts with Maven meta data) there isn't usually Ivy meta data (ivy.xml). And the Maven 2 layout is [organisation]/[module]/[revision]/[artifact]-[revision].[ext].

We have only to provide the following information

<url name="archiva" m2compatible="true">
  <artifact pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> 
  </url>
</chain>

or

  <settings defaultResolver="archiva"/>
  <resolvers>
<ibiblio name="archiva" m2compatible="true" root="http://.../archiva/repository/internal/[organization]/[module]/[revision]/[artifact]-[revision].[ext]"/&gt;
  </resolvers>
Gregory Boissinot
Using Archiva to achieve proxying is not in the scope of the question. You can do that in a number different ways. The problem is to use that from ivy in a similar way it's used in maven.
Matthias Hryniszak
+2  A: 

You need to create a public resolver that does what you want (more details @ Ivy docs)

Basically save the following snippet under $USERHOME/.ivy2/ivysettings-public.xml. This should do the trick.

<ivysettings> 
  <resolvers> 
    <ibiblio name="public" m2compatible="true" root="http://localhost:8081/content/groups/public"/&gt; 
  </resolvers> 
</ivysettings>
  • The unmodified standard installation has 'nexus' in the URL!
  • If you need to deploy artifacts, I think the solution is to do something similar to the shared resolver (see link to docs above), but I haven't tried.
  • I changed your local URL to resolve to the standard 'content/groups/public' which is better since in the maven settings fragment above you're passing all calls through the mirror, not just the ones to central. Just add any additional repositories to that group in the Nexus UI as they come up and you should be fine.
  • If your project loads it's own ivysettings which doesn't honor the defaults, then these settings will not get loaded and you're again back at zero :(
Heron
I'll try it out but it seems that the fact that project's ivysettings.xml overrides completly the user's configuration it is not going to be useful for me. But thanks anyway!
Matthias Hryniszak