You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by "KARR, DAVID" <dk...@att.com> on 2014/01/10 22:39:47 UTC

How could I make "retrieve" also copy into local Maven repo, just like Maven does

I just started using Ivy, to help an Ant build that needs to get a local component built from Maven.

What I've done with Ivy all works.  It retrieves the artifacts from either my local Maven repo or our intranet repo.

There is one thing that this doesn't do that I'd like to have happen.

If it doesn't find it in the local Maven repo, it gets it from the intranet repo, but in that case it downloads it directly from the intranet repo into the "lib" directory of the project.  If this were Maven doing this build, it would have also copied the artifact into the local Maven repo.  I'd prefer for this to happen.  How do I set up some "retrieve" magic that would also install the artifact into the local Maven repo?

If it matters, here is an elided version of my "ivysettings.xml":
----------------------
<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">
            <filesystem name="local-maven2" m2compatible="true" >
                <artifact pattern="${m2-pattern}"/>
                <ivy pattern="${m2-pattern}"/>
            </filesystem>
            <ibiblio name="...Snapshots" m2compatible="true"
		     root="http://...att.com:xxxx/nexus/content/repositories/...-snapshots"/>
            <ibiblio name="...Thirdparty" m2compatible="true"
		     root="http://...att.com:xxxx/nexus/content/repositories/...-3rd-party"/>
            <ibiblio name="central" m2compatible="true"/>
        </chain>
    </resolvers>
</ivysettings>
-------------------

Re: How could I make "retrieve" also copy into local Maven repo, just like Maven does

Posted by Marc De Boeck <md...@gmail.com>.
You cannot use the ant-tasks ivy:resolve or ivy:retrieve to copy
module-artifacts from one repo to another.
Instead, you could use the task ivy:install for this purpose. But in your
case, I don't think this is really necessary.

You should know that Ivy has a concept of a cache (the ivy-cache), which
does the same same thing as you want to do with the local repo:

Whenever you resolve a particular module from a set of repositories, the
asked revision is searched in the configured repositories and when found it
is copied with all its artifacts to the ivy-cache. From there, the
artifacts can be copied to the requested location (for example to your
lib-directory) using the ivy:retrieve task. The next time you ask for the
same revision of that module, Ivy will simply lookup the revision in its
cache, and if it finds it there it will use the artifacts found there. So
no additional download will be done.

The concept of the ivy-cache is different from Maven: in Maven the local
repo plays the role of a repository for your own built artifacts and the
role of a cache for artifacts coming from
other repositories. I would recommend not to to copy this behaviour with
Ivy.

Regards,
Marc




2014/1/10 KARR, DAVID <dk...@att.com>

> I just started using Ivy, to help an Ant build that needs to get a local
> component built from Maven.
>
> What I've done with Ivy all works.  It retrieves the artifacts from either
> my local Maven repo or our intranet repo.
>
> There is one thing that this doesn't do that I'd like to have happen.
>
> If it doesn't find it in the local Maven repo, it gets it from the
> intranet repo, but in that case it downloads it directly from the intranet
> repo into the "lib" directory of the project.  If this were Maven doing
> this build, it would have also copied the artifact into the local Maven
> repo.  I'd prefer for this to happen.  How do I set up some "retrieve"
> magic that would also install the artifact into the local Maven repo?
>
> If it matters, here is an elided version of my "ivysettings.xml":
> ----------------------
> <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">
>             <filesystem name="local-maven2" m2compatible="true" >
>                 <artifact pattern="${m2-pattern}"/>
>                 <ivy pattern="${m2-pattern}"/>
>             </filesystem>
>             <ibiblio name="...Snapshots" m2compatible="true"
>                      root="http://...att.com:
> xxxx/nexus/content/repositories/...-snapshots"/>
>             <ibiblio name="...Thirdparty" m2compatible="true"
>                      root="http://...att.com:
> xxxx/nexus/content/repositories/...-3rd-party"/>
>             <ibiblio name="central" m2compatible="true"/>
>         </chain>
>     </resolvers>
> </ivysettings>
> -------------------
>