将公共 Maven 存储库与 ivy 一起使用 [英] Use public maven repository with ivy

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

问题描述

我有一个 ivy.xml 包含

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

整个 superwidget 内容托管在位于 http://example.com/m2/ 的 maven 存储库中.常春藤文档提到解析器,但它似乎假设常春藤存储库.如何将单个非官方 Maven 存储库添加到我的 ivy 设置中以仅由单个模块使用?(或者换句话说,什么对应于 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>

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

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