将公共 Maven 存储库与 ivy 一起使用

发布于 2024-10-15 01:15:37 字数 619 浏览 4 评论 0原文

我有一个 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/。 ivy文档提到解析器,但它似乎假设常春藤存储库。如何将单个非官方 Maven 存储库添加到我的 ivy 设置中,以便仅由单个模块使用? (或者换句话说,什么对应于 ivy 中 maven 的 标记?)没什么花哨的,所以我希望在 ivy.xml 中有一行代码。

I have an ivy.xml containing

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

隐诗 2024-10-22 01:15:37

您需要添加一个 ivysettings.xml 文件,其中列出了以下存储库 (

<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 中是不需要的,因为它只支持一种类型的存储库。

如果您想要真正喜欢,您可以控制哪个存储库提供特定模块:

<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>

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>

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>
梦魇绽荼蘼 2024-10-22 01:15:37

我更喜欢包含 SpringSource 的 EBR 和 Maven Central 的链式解析器,如下所示:

<ivysettings>
    <settings defaultResolver="spring-chain" />
    <resolvers>
        <chain name="spring-chain">
            <url name="com.springsource.repository.bundles.release">
                <ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
                <artifact pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
            </url>
            <url name="com.springsource.repository.bundles.external">
                <ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
                <artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
            </url>
            <ibiblio name="ibiblio" m2compatible="true"/>
        </chain>
    </resolvers>
</ivysettings>

虽然我不直接使用它们,但我更喜欢 创建并控制我自己的本地 Ivy 存储库

I prefer chained resolvers that include SpringSource's EBR and Maven Central too, like this:

<ivysettings>
    <settings defaultResolver="spring-chain" />
    <resolvers>
        <chain name="spring-chain">
            <url name="com.springsource.repository.bundles.release">
                <ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
                <artifact pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
            </url>
            <url name="com.springsource.repository.bundles.external">
                <ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
                <artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
            </url>
            <ibiblio name="ibiblio" m2compatible="true"/>
        </chain>
    </resolvers>
</ivysettings>

Although I do not use them directly, I prefer to create and control my own local Ivy repository.

嘦怹 2024-10-22 01:15:37

这是尝试保留 Ivy 的默认行为并仅添加存储库,即 maven.tmatesoft.com 存储库

<ivysettings>
    <settings defaultResolver="default"/>

    <!-- These "magic lines" are pulled from: https://ant.apache.org/ivy/history/latest-milestone/tutorial/defaultconf.html -->
    <include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
    <include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
    <include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
    <include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
    <include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
    <resolvers>
        <!-- Custom Repos here -->
        <ibiblio name="tmatesoft" m2compatible="true" root="https://maven.tmatesoft.com/content/repositories/releases/"/>
        <!--<filesystem name="internal">-->
            <!--<ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/>-->
            <!--<artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/>-->
        <!--</filesystem>-->
    </resolvers>
    <chain name="default" returnFirst="true" checkmodified="true" changingPattern=".*SNAPSHOT">
        <!-- These two are magic lines from the default conf -->
        <resolver ref="local"/>
        <resolver ref="main" />

        <!-- Custom Repos here -->
        <resolver ref="tmatesoft" />
    </chain>
    <modules>
        <module organisation="org.tmatesoft.hg4j" name=".*" resolver="tmatesoft"/>
    </modules>
</ivysettings>

Here's one that tries to keep Ivy's default behavior and just add on repository, the maven.tmatesoft.com repo

<ivysettings>
    <settings defaultResolver="default"/>

    <!-- These "magic lines" are pulled from: https://ant.apache.org/ivy/history/latest-milestone/tutorial/defaultconf.html -->
    <include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
    <include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
    <include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
    <include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
    <include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
    <resolvers>
        <!-- Custom Repos here -->
        <ibiblio name="tmatesoft" m2compatible="true" root="https://maven.tmatesoft.com/content/repositories/releases/"/>
        <!--<filesystem name="internal">-->
            <!--<ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/>-->
            <!--<artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/>-->
        <!--</filesystem>-->
    </resolvers>
    <chain name="default" returnFirst="true" checkmodified="true" changingPattern=".*SNAPSHOT">
        <!-- These two are magic lines from the default conf -->
        <resolver ref="local"/>
        <resolver ref="main" />

        <!-- Custom Repos here -->
        <resolver ref="tmatesoft" />
    </chain>
    <modules>
        <module organisation="org.tmatesoft.hg4j" name=".*" resolver="tmatesoft"/>
    </modules>
</ivysettings>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文