- Home
- Download
- Documentation (2.0.0-beta1)
- History
- Trunk
- 2.x
- 2.0.x
- 2.0.0-beta1
- 2.0.0-alpha2
- 2.0.0-alpha-1
- 2.0.x
- 1.x
- 0.x
- Get Involved
- Search
Multiple Resolvers
This example is an illustration of how artifacts can be retrieved by multiple resolvers. Using multiple resolvers is very important when using continous integration. Indeed, in such environments, you can use multiple repositories and so multiple resolvers to retrieve both released versions of projects than continous integrated versions produced for example with cruise-control. In our example, we will just show how to use two resolvers, one on a local repository and one using ibiblio repository.
project description
the project : chained-resolvers
The project is very simple and contains only one test class : example.HelloIt depends on two libraries apache commons-lang and a little test library (sources are included in jar file). The test library is used by the project to uppercase a string, and commons-lang is used to capitalize the same string.
Here is the content of the project:
- build.xml : the ant build file for the project
- ivy.xml : the ivy project file
- src\example\Hello.java : the only class of the project
<ivy-module version="1.0">As we expect, the ivy file declares to be dependent on the two libraries that the project use : apache commons-lang.jar and test.jar.
<info organisation="jayasoft" module="chained-resolvers" />
<dependencies>
<dependency org="apache" name="commons-lang" rev="2.0" />
<dependency name="test" rev="1.0" />
</dependencies>
</ivy-module>
the ivy settings
The ivy settings is made in the config directory it contains only one file: ivysettings.xml.Let's analyse it.
<ivysettings>
<settings defaultResolver="chain-example" />
<resolvers>
<chain name="chain-example">
<filesystem name="libraries">
<artifact pattern="${ivy.settings.dir}/repository/[artifact]-[revision].[type]" />
</filesystem>
<ibiblio name="ibiblio" />
</chain>
</resolvers>
</ivysettings>
the settings tag
This tag initializes ivy with some parameters. Here only one is used, the name of the resolver to use by default.the resolvers tag
Under this tag, we can find the description of the resolvers that ivy will use. In our example, we have only one resolver, called "chain-example", which is quite special as it defines a list (a chain) of resolvers.The resolvers put in the chain are :
- libraries : it is a file resolver. This one is configured to look for artifacts in the "repository" sub directory of the directory that contains the ivysettings.xml file.
- ibiblio : this resolver is a special one. It looks in the ibiblio maven repository to retrieve the libraries.
walkthrough
step 1 : preparation
Open a DOS or shell window, and go to the "chained-resolvers" directory.step 2 : clean directory tree
On the prompt type : antThis will clean up the entire project directory tree and ivy cache. You can do it each time you want to clean up this example.
step 3 : run the project
Goto chainedresolvers-project directory. And simply run ant.I:\chained-resolvers\chainedresolvers-project>ant
Buildfile: build.xml
configure:
:: Ivy 1.0-rc3 - 20050421161206 :: http://ivy.jayasoft.org/ ::
resolve:
:: resolving dependencies :: jayasoft/chained-resolvers-working@xmen
confs: [default]
downloading http://www.ibiblio.org/maven/commons-lang/jars/commons-lang-2.0.jar(2.0) ...
.................................... (165kB)
[SUCCESSFUL ] apache/commons-lang-2.0/commons-lang.jar[jar] (5390ms)
downloading file:/I:/chained-resolvers/config/repository/test-1.0.jar(1.0) ...
. (1kB)
[SUCCESSFUL ] jayasoft/test-1.0/test.jar[jar] (16ms)
:: resolution report ::
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 2 | 2 | 0 | 0 || 2 | 2 |
---------------------------------------------------------------------
:: retrieving :: jayasoft/chained-resolvers
confs: [default]
2 artifacts copied, 0 already retrieved
run:
[mkdir] Created dir: I:\chained-resolvers\chainedresolvers-project\build
[javac] Compiling 1 source file to I:\chained-resolvers\chainedresolvers-project\build
[java] standard message :example world !
[java] capitalized by org.apache.commons.lang.WordUtils : Example World !
[java] upperCased by test.StringUtils : EXAMPLE WORLD !
BUILD SUCCESSFUL
Total time: 9 seconds