I have a special situation where I need to package up some jars, and I need BOTH versions of a jar. My ivy definitions looks like this:
<dependency org="blah" name="blahname" rev="1.0.0" conf="baseline->default" />
I would like the same dependency resolved twice, once with version 1.0.0 and another with say version 2.0.0. Is that possible? What's the easiest way to achieve this.
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
来源:https://stackoverflow.com/questions/10941293/ivy-resolve-same-dependency-twice-with-two-different-versions-to-two-differ