1

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>

2 Answers2

2

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.

Akber Choudhry
  • 1,755
  • 16
  • 24
  • Thanks @akberc (+1) - please see the update to my question. I have included my `` definition. Am I to understand that a `` task will look for dependencies in every resolver (urlResolver, localFileResolver and publisherResolver) with a find-first strategy? Thanks again! –  Feb 21 '13 at 17:29
  • I assume that the publishResolver will be referenced by name in a publish task. For resolution, both resolvers in the chain will be invoked. Since you have specified returnFirst, the localFileResolver will not be invoked - you may want to have it the other way around. In your config, the 'find-first' strategy is limited to the chain, and it will only refer to the third one if the module is not found in both resolvers in the chain. Also, see 'dual' with chains. – Akber Choudhry Feb 21 '13 at 17:55
0

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

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185