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