常春藤 - 两次解决相同的依赖项(使用两个不同的版本),到两个不同的文件 [英] Ivy - resolve same dependency twice (with two different versions), to two different files

查看:27
本文介绍了常春藤 - 两次解决相同的依赖项(使用两个不同的版本),到两个不同的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个特殊的情况,我需要打包一些 jar,并且我需要一个 jar 的两个版本.我的常春藤定义如下所示:

I have a special situation where I need to package up some jars, and I need BOTH versions of a jar. My ivy definitions looks like this:

<dependency org="blah" name="blahname" rev="1.0.0" conf="baseline->default" />

我希望相同的依赖项解决两次,一次是 1.0.0 版,另一个是 2.0.0 版.那可能吗?实现这一目标的最简单方法是什么.

I would like the same dependency resolved twice, once with version 1.0.0 and another with say version 2.0.0. Is that possible? What's the easiest way to achieve this.

推荐答案

使用 ivy 配置来创建和管理自定义依赖项组.

Use ivy configurations to create and manage custom groups of dependencies.

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>

    <configurations>
        <conf name="group1" description="First group of dependencies"/>
        <conf name="group2" description="Second group of dependencies"/>
    </configurations>

    <dependencies>
        <dependency org="commons-lang" name="commons-lang" rev="2.6" conf="group1->default"/>
        <dependency org="commons-lang" name="commons-lang" rev="2.0" conf="group2->default"/>
    </dependencies>

</ivy-module>

build.xml

<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">

    <target name="resolve">
        <ivy:resolve/>

        <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]"/>
    </target>

</project>

注意事项:

  • 此示例使用检索任务来填充lib"目录.另请参阅缓存路径"和缓存文件集"任务.

Lib 目录中填充了所需的 jar.

Lib directory is populated with the desired jars.

$ tree
.
|-- build.xml
|-- ivy.xml
`-- lib
    |-- group1
    |   `-- commons-lang-2.6.jar
    `-- group2
        `-- commons-lang-2.0.jar

这篇关于常春藤 - 两次解决相同的依赖项(使用两个不同的版本),到两个不同的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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