tags:

views:

35

answers:

3

Hereabouts, we use a Sonatype Maven repository. This is jolly nice for our maven projetcs, but we have a legacy application that uses Ant+IVY for dependency management which now needs a dep from Maven.

My IVY settings file looks like:

<ivysettings>
    <property name="dsnexus-root" value="http://internal-url/" override="false"/>

    <credentials host="hostname" username="username" passwd="XXXX"/>

    <!-- ... -->

    <resolvers>
        <chain name="shared">
            <url name="shared-default">
                <!-- ... -->
            </url>
            <url name="dsnexus-public" m2compatible="true">
                <artifact pattern="${dsnexus-root}/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
            </url>
        </chain>
    </resolvers>

    <modules>
        <module organisation=".*" name=".*" resolver="shared"/>
    </modules>

    <!-- ... -->
</ivysettings>

But when I try to resolve my deps it doesn't find anything from the internal repo

e.g.

module not found: xerces#xercesImpl;2.9.1
==== shared-default: tried
...
==== dsnexus-public: tried
-- artifact xerces#xercesImpl;2.9.1!xercesImpl.jar:
http://internal-url/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar

And of course, the dep does exist on that url.

I have also tried

<ibiblio name="dsnexus-public" 
    root="${dsnexus-root}" 
    m2compatible="true" 
    namespace="maven2"/>

and got the same result.

My guess is there is something about the credentials I have got wrong.

A: 

I normally use the ibiblio resolver when talking to nexus.

<ibiblio name="reponame" m2compatible="true" root="http://nexus-url/reponame"/&gt;
Mark O'Connor
I have tried this, and I'm afraid with the same results.
Paul McKenzie
Are you located behind a proxy server? Pure speculation on my part. I'm trying to establish why ivy fails to retrieve an URL that exists via your web browser. Try running ANT in verbose mode, you'll get more details that might shed some light on the failure.
Mark O'Connor
+1  A: 

You should also specify the realm with your credentials, something like this:

<credentials host="hostname" realm="Sonatype Nexus Repository Manager" username="username" passwd="xxx"/>
Maarten Coene
Hmm, I will try this. How would I discover the actual name of the realm I wonder?
Paul McKenzie
A: 

Here, try this:

<ivysettings>
  <settings defaultResolver="nexus" 
            checkUpToDate="true" />

  <credentials host="localhost" 
           realm="Sonatype Nexus Repository Manager" 
           username="admin"
           passwd="admin123"/>
  <resolvers>
    <ibiblio name="nexus" m2compatible="true" 
             root="http://localhost:8081/nexus/content/groups/public/"/&gt;
    <url name="releases" m2compatible="true">
        <artifact pattern="http://localhost:8081/nexus/content/repositories/releases/[organization]/[module]/[revision]/[artifact]-[revision].[ext]"/&gt;
        <ivy pattern="http://localhost:8081/nexus/content/repositories/releases/[organization]/[module]/[revision]/ivy-[revision].xml"/&gt;
    </url> 
  </resolvers>
</ivysettings>

Works perfectly for me with Nexus 1.7.1. Let me know if you have any problems.

tobrien