Ivy - resolve same dependency twice (with two different versions), to two different files

混江龙づ霸主 提交于 2019-12-04 14:32:33

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

Example

ivy.xml

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

Notes:

  • This example uses the retrieve task to populate the "lib" directory. See also the "cachepath" and "cachefileset" tasks.

Results

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!