user1768830
user1768830

Reputation:

How to specify which Ivy resolver to use

My understanding is that <ivy:resolve/> copies dependencies from the configured repo into the local Ivy cache (rooted under ${USER_HOME}/.ivy2). But after looking at the task's docs, I was surprised to find that there is no resolver attribute, like:

<ivy:resolve file="ivy.xml" conf="compile" resolver="theResolverToUse"/>

So I ask: how do you specify which resolver to use, especially if (in ivysettings.xml), you can define 1+ resolvers? Thanks in advance.

Update:

For instance, here's a snippet of the resolver defined in my (emerging) ivysettings.xml:

<resolvers>  
    <chain name="chainResolver" returnFirst="true">
        <url name="urlResolver">
            <ivy pattern="${ivyRepoRoot}/module_descriptors/${ivyModDescriptorPattern}"/>
            <artifact pattern="${ivyRepoRoot}/artifacts/${ivyArtifactPattern}"/>
        </url>

        <filesystem name="localFileResolver">
            <artifact pattern="${user.home}/.ivy2/local-cache/[artifact]-[revision].[ext]"/>
        </filesystem>
    </chain>  
    <sftp name="publisherResolver" user="fizz" userPassword="buzz" host="example.com">
        <ivy pattern="sftp://example.com:22/usr/local/apache/htdocs/ivy/module_descriptors/${ivyModDescriptorPattern}"/>
        <artifact pattern="sftp://example.com:22/usr/local/apache/htdocs/ivy/artifacts/${ivyArtifactPattern}"/>
    </sftp>
</resolvers>

Upvotes: 1

Views: 3666

Answers (2)

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 78021

Chain resolvers are handy, but if you want more control I'd suggest using a modules section as explained in the following answer:

Upvotes: 0

Akber Choudhry
Akber Choudhry

Reputation: 1785

In Ivy, resolvers and their relationships, priorities and chains are defined separately from the resolve task.

Multiple resolvers can be chained together and in chained resolvers, pay special attention to the first resolver in the chain and the notion of 'find first'.

If resolvers and/or chains are configured properly, you should not have to choose which resolver to use. This comes in very handy when resolvers have different behaviour in different environments.

Upvotes: 2

Related Questions