A way to control dependencies ranges for upstream dependencies using Ivy?

耗尽温柔 提交于 2019-12-18 09:40:31

问题


I am using Ivy to assemble a composite application from internally developed and third party libraries. Ivy is used to manage dependencies for building the above libraries. For each library there are multiple compatible versions that are available and that may be used within the assembled application. The question is how can I direct ivy NOT to choose the latest version of a dependency. Let me illustrate with the following example:

  • A[3]:B[2.5.+],C[1.3.+]

meaning that package A depends on the B package of any version 2.5.0-2.5.X (within 2.5 branch there are no breaking changes, which means all versions within that range are compatible). Same logic applies to C.

At application assembly time I define an Ivy.xml file that simply says:

  • Application:A[3]

This will instruct Ivy to extract all the latest versions of B and C in the ranges that A is compatible with. Due to some business constraints I want to also "say": "instead of the latest version of B in the defined range use version 2.5.6 specifically" (let's say that 2.5.7 also exists). So, instead of above I want to say something like:

  • Application:A[3],B[2.5.6]

The problem is that Ivy will evict B[2.5.6] in favor of 2.5.7. So a conflict manager of some sort will have to be used. I was thinking of latest-compatible with hope that it would allow specify an additional range. I cannot find an example of that. That is given that my guess is correct, of course...


回答1:


The force attribute on the dependency declaration may be all you need.

If that doesn't work, I'd suggest reading the ivy documentation on conflict management:

  • http://ant.apache.org/ivy/history/latest-milestone/ivyfile/conflicts.html
  • http://ant.apache.org/ivy/history/latest-milestone/settings/conflict-managers.html



回答2:


The answer was so close I could not see it...

<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">    
<info organisation="some" module="application" />

<publications>
    <artifact name="application" ext="zip" />
</publications>

<dependencies>
    <dependency org="some" name="A" rev="2.8.+" branch="2.8">
        <artifact name="A" ext="zip"/>
    </dependency>
    <dependency org="some" name="B" rev="2.5.6" branch="2.5">
        <artifact name="B" ext="zip"/>
    </dependency>
    <conflict org="some" module="B" rev="2.5.6"/>
</dependencies>

hope it helps someone else :-)



来源:https://stackoverflow.com/questions/6627100/a-way-to-control-dependencies-ranges-for-upstream-dependencies-using-ivy

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