在Ivy上使用公共Maven存储库 [英] Use public maven repository with ivy

查看:155
本文介绍了在Ivy上使用公共Maven存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ivy.xml包含

<dependencies>
  <dependency org="commons-lang" name="commons-lang" rev="2.4"/>
  <dependency org="foo-bar" name="superwidgets" rev="1.5"/>
</dependencies>

整个超级组件的内容都存放在 http://example.com/m2/的Maven存储库中. .常春藤文档提及解析器,但它似乎是在假定常春藤仓库.如何将单个非官方Maven存储库添加到常春藤设置中,以仅由单个模块使用? (或者换句话说,与ivy中maven的<repository>标记相对应?)没什么花哨的,所以我希望我的ivy.xml中有一个内衬.

The whole superwidget stuff is hosted in a maven repository at http://example.com/m2/. The ivy documentation mentions resolvers, but it seems to assume an ivy repository. How can I add a single unofficial maven repository to my ivy settings to be used only by a single module? (Or put another way, what corresponds to maven's <repository> tag in ivy?) Nothing fancy, so I'd expect a one-liner in my ivy.xml.

推荐答案

您需要添加带有以下存储库的 ivysettings.xml 文件(

You need to add an ivysettings.xml file with the following repositories listed (resolvers in ivy speak)

<ivysettings>
    <settings defaultResolver="chain"/>
    <resolvers>
        <chain name="chain">
            <ibiblio name="central" m2compatible="true"/>
            <ibiblio name="example" m2compatible="true" root="http://example.com/m2/"/>
        </chain>
    </resolvers>
</ivysettings>

在我看来,将依赖项声明(ivy.xml)与检索机制(settings.xml)分开更有意义.在Maven中不需要此功能,因为它仅支持一种类型的存储库.

In my opinion it makes more sense to separate the dependency declaration (ivy.xml) from the mechanism of retrieval (settings.xml). This is not needed in Maven because it only supports one type of repository.

如果您真的想花哨的话,可以控制哪个存储库为特定模块服务:

If you want to get really fancy you can control which respository serves up a particular module:

<ivysettings>
    <settings defaultResolver="central"/>
    <resolvers>
        <ibiblio name="central" m2compatible="true"/>
        <ibiblio name="example" m2compatible="true" root="http://example.com/m2/"/>
    </resolvers>
    <modules>
        <module organisation="foo-bar" name="superwidgets" resolver="example"/>
    </modules>
</ivysettings>

这篇关于在Ivy上使用公共Maven存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆