Reputation: 107030
I have a project that has two different jars with both containing some of the same classes. What I need is for it to use the classes from Jar "A" before Jar "B". In normal Java compilation (and with Ant), I could specify the order of the classpath itself. This way, I could guarantee that classes in Jar "A" will be used before the classes in Jar "B".
Is there a way to do this in Ivy?
The only way I could think of doing this is to create two separate configurations in my ivy.xml
:
<dependency org="com.vegibank" name="a.jar"
rev="1.0" conf="foo->default"/>
<dependency org="com.vegibank" name="b.jar"
rev="1.0" conf="compile->default"/>
Then create two separate pathclass references:
<ivy:cachepath pathid="compile.foo.classpath"
conf="foo"/>
<ivy:cachepath pathid="compile.normal.classpath"
conf="compile"/>
Then in <javac/>
, I could specify the paths:
<javac ...>
<classpath refid="compile.foo.classpath"/>
<classpath refid="compile.normal.classpath"/>
</javac>
However, I assume there must be a way to guarantee the way jars are loaded into the classpath when Ivy is doing its resolve.
Is there a way of doing this?
Upvotes: 1
Views: 3528
Reputation: 2013
Every Ivy Ant task and even IvyDE is respecting the order of the declaration of the dependencies in the ivy.xml file. So if in your ivy.xml you declare a dependency on a.jar before b.jar, the resulting classpath will have a.jar first and b.jar after.
Upvotes: 1