Here is an example. We are dealing with ivy 2.1 and with ant 1.8.3. One of our project has a direct dependency of 'math' version 5.1 and a 'common' version 1.4.6. But 'common' has a direct dependency of 'math' version 5.2.
<dependencies>
<dependency org="home" name="math" revision="5.1" conf="runtime" />
<dependency org="home" name="common" revision="1.4.6" conf="runtime" />
</dependencies>
It is sure that the resolution will gather the 'math' version 5.2 owing to the 'common's direct dependency. Since it causes compiler error I want to use 'math' 5.1 instead therefore I tried to put the proper override tag into the ivy xml after all the dependency tags:
<override org="home" module="math" rev="5.1" />
It should work and gather only the version 5.1. And it turned out that it actually works in IntelliJ IDEA 14 and in Eclipse 4.3, so after the respective ivy plugin's resolve I can see only 'math' version 5.1 in the project's libraries. I have checked the dependency graph in the Ivy Visualizer view and it seemed fine.
However when I use one of the suitable ant build target it fails with compilation error because it resolves 'math' version 5.2 rather than 5.1(!!).
Based on the ivy's documentation the override
"can be useful when a direct dependency is bringing a transitive dependency for which you want to change the revision, without actually declaring a dependency on it"
Also it is claimed that
Overriding is done before any else, in a phase called dependency descriptor mediation. The transitive dependency then behave exactly as if it were declared with the new value.
So it should work with ant build as well but behaves contradictory to the expectation. Eventually We figured out that the force attribute (force="true") of the dependency tag is the rescue which results the expected library structure after the IDEs' and after the ant build resolution. Based on the ivy documentation:
...the dependency element also supports an a force attribute (since 0.8), which gives an indication to conflicts manager to force the revision of a dependency to the one given here.
Why override tag causes contradictory behavior of the different tools and why force="true" works? I would appreciate if somebody can highlight the (slight?) differences.