Ivy via Nexus proxy
Asked Answered
B

5

12

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</url>
  </mirror>
</mirrors>

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

Birdwell answered 23/6, 2009 at 16:58 Comment(0)
B
6

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.

Breger answered 8/7, 2009 at 16:26 Comment(4)
Thanks - that's what I've been afraid of. Ivy just doesn't live to my expectations after working with Maven.Birdwell
Ivy just has a different way of approaching dependency management.Austerity
-1 to Mark's comment. It's not a different way, it's a missing feature. As an analogy: Imagine you're using a browser that has no settings for 'Proxy Configuration', it doesn't mean it approaches web browsing in a different way, it means the software is unusable (without hacks) when you actually need to set a proxy.Abstain
This answer is either wrong or outdated by @Heron's comment below.Metamorphic
B
8

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"/> 
  </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 :(
Burmese answered 12/3, 2010 at 19:53 Comment(4)
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!Birdwell
The problem with that is that one should be able to get the project from repository and just build it. With any modification to the local environment it's all at the window... But thanks anyway for your response!Birdwell
Tried this technique with svn.apache.org/repos/asf/ant/core/trunk/… and it did not seem to have any effect; messages referred to "downloading repo1.maven.org/maven2..." as before.Thyself
Does not seem to work for me. I had to add <ivy:settings file="/Users/wdb/.ivy2/ivysettings-public.xml" /> in my ant file as well, but then it fails with: no resolver found for net.wimpi#jamodRubefaction
B
6

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.

Breger answered 8/7, 2009 at 16:26 Comment(4)
Thanks - that's what I've been afraid of. Ivy just doesn't live to my expectations after working with Maven.Birdwell
Ivy just has a different way of approaching dependency management.Austerity
-1 to Mark's comment. It's not a different way, it's a missing feature. As an analogy: Imagine you're using a browser that has no settings for 'Proxy Configuration', it doesn't mean it approaches web browsing in a different way, it means the software is unusable (without hacks) when you actually need to set a proxy.Abstain
This answer is either wrong or outdated by @Heron's comment below.Metamorphic
R
2

This is how I made it work (The answer from @Heron did not work for me):

Create a file with this content:

<ivysettings>
  <settings defaultResolver="default"/>
  <property name="m2-pattern" value="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]" override="false" />
  <resolvers>
    <chain name="default">
        <ibiblio name="public" m2compatible="true" root="http://nexus-server:8081/nexus/content/groups/public"/>
    </chain>
  </resolvers>
</ivysettings>

Refere to it from the ant build:

<ivy:settings file="/Users/wdb/.ivy2/ivysettings-public.xml" />

Ivy is now able to resolve dependencies from my nexus repository.

Rubefaction answered 25/3, 2013 at 15:41 Comment(0)
C
-1

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>
Czarina answered 6/10, 2009 at 15:30 Comment(2)
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.Birdwell
I don't think such an option exists in Ivy.Aconite
P
-1

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]"/>
  </resolvers>
Plenipotentiary answered 4/11, 2009 at 21:43 Comment(1)
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.Birdwell

© 2022 - 2024 — McMap. All rights reserved.