Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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 :(

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.

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>

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top