Return-Path: Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: (qmail 51773 invoked from network); 8 Jul 2010 10:05:14 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Jul 2010 10:05:14 -0000 Received: (qmail 89916 invoked by uid 500); 8 Jul 2010 10:05:14 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 89802 invoked by uid 500); 8 Jul 2010 10:05:13 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 88535 invoked by uid 99); 8 Jul 2010 10:05:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jul 2010 10:05:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jul 2010 10:03:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 542C02388C2C; Thu, 8 Jul 2010 10:00:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r961685 [2/45] - in /ant/ivy/site/target/history/2.2.0-rc1: ./ configuration/ configuration/caches/ configuration/macrodef/ configuration/namespace/ dev/ images/ ivyfile/ js/ resolver/ samples/ settings/ settings/caches/ settings/macrodef/ ... Date: Thu, 08 Jul 2010 10:00:27 -0000 To: notifications@ant.apache.org From: maartenc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100708100147.542C02388C2C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: ant/ivy/site/target/history/2.2.0-rc1/book.html URL: http://svn.apache.org/viewvc/ant/ivy/site/target/history/2.2.0-rc1/book.html?rev=961685&view=auto ============================================================================== --- ant/ivy/site/target/history/2.2.0-rc1/book.html (added) +++ ant/ivy/site/target/history/2.2.0-rc1/book.html Thu Jul 8 10:00:21 2010 @@ -0,0 +1,5823 @@ + + + + + + + + + +Documentation (2.2.0-rc1) | Ivy @version@ + + + + + + + +
+ + + + + + + + + +
+
Documentation (2.2.0-rc1)

Welcome to the official Ivy documentation.

What is Ivy?

+Ivy is a tool for managing (recording, tracking, resolving and reporting) project dependencies. It is characterized by the following:
    +
  1. flexibility and configurability - Ivy is essentially process agnostic and is not tied to any methodology or structure. Instead it provides the necessary flexibility and configurability to be adapted to a broad range of dependency management and build processes.
  2. + +
  3. tight integration with Apache Ant - while available as a standalone tool, Ivy works particularly well with Apache Ant providing a number of powerful Ant tasks ranging from dependency resolution to dependency reporting and publication.
  4. +
+Ivy is open source and released under a very permissive Apache License.

Ivy has a lot of powerful features, the most popular and useful being its flexibility, integration with ant, and its strong transitive dependencies management engine.

The transitive dependencies management is a feature which lets you get dependencies of your dependencies, transitively. In order to address this general problem, ivy needs to find metadata about your modules, usually in an ivy file. To find the metadata and your dependencies' artifacts (usually jars), Ivy can be configured to use a lot of different repositories.

About this doc

+
+Tip: The menu on the left is dynamic, you can click on the arrows to browse the menu without going to each page. +
+This documentation has been migrated from the old Ivy web site hosted by Jayasoft, feel free to report any problem on the mailing-lists.

If you browse this documentation from your installation of Ivy, you can also check the online version for the latest updates.

You can also browse this documentation offline either by downloading the documentation distribution, or by checking out the doc directory from svn. This documentation uses xooki as its documentation engine, so you can very easily edit it and submit patches when you browse it from source.

A printer-friendly version of this whole documentation is also provided for your convenience.

Since Ivy 2.0.0-alpha-2, we keep an online history of the docu mentation. You can thus browse history versions online (in the history menu in the web site) and even check the trunk version documentation currently in development.

For earlier versions, we suggest downloading the documentation to browse the documentation corresponding to the version you use. The full history of Ivy versions with corresponding links for download is available in the history menu on the web site.

Other places to go

+Check out Ivy features.
Read our FAQ.
Ask for help on our mailing lists.
Report a bug or feature request in our issue tracking system.
Check external tools and resources.

Overview

+This documentation is composed of three main parts: +
    +
  • Tutorials
  • +The tutorials is the best way to begin to play with Ivy. You will easily and quickly learn the basics of Ivy.
  • Reference
  • +The reference documentation gives you all the details of Ivy.
    The introduction part is particularly useful: it defines some vocabulary, explains main concepts such as dependency resolvers and patterns, and gives an overview of how ivy works internally.
    It's also in the reference doc that you will find all you always dreamed to know about ivy settings, ivy files, and ivy use (especially with ant).
  • Developer doc
  • +The developers's doc is useful for users who would like to extend Ivy or build it from source. It's also the documentation used by the Ivy team, so you will also find information about how we make releases. +
+
Release Notes

Announcement

+ +
+Jul 05, 2010 - The Ivy project is pleased to announce its 2.2.0-rc1 release.
This is the first candidate release of Ivy 2.2.0.

Ivy is a tool for managing (recording, tracking, resolving and
reporting) project dependencies, characterized by flexibility,
configurability, and tight integration with Apache Ant.

This is a release candidate for 2.2.0 final, meaning that no changes
except bug fixes will occur between this release candidate and 2.2.0 final.
Problems found at this phase can be fixed in the final release, so now
is a good time to download and use it. If no outstanding bugs are reported
in the coming weeks, this release candidate will be promoted as the 2.2.0
final release.

Key features of the 2.2.0 release are
* enhanced Maven2 compatibility, with several bug fixes and more
pom features covered
* new parent mechanism for Ivy files
* numerous bug fixes as documented in Jira and in the release notes

We encourage all users of Ivy to update to this new version.

Issues should be reported to:
https://issues.apache.org/jira/browse/IVY

Download the 2.2.0-rc1 release at:
http://ant.apache.org/ivy/download.cgi

More information can be found on the Ivy website:
http://ant.apache.org/ivy/

Regards,
Maarten Coene +
+ +

Release Notes

+ +CONTENTS
1. What is Apache Ivy?
2. Status of this release
3. How to Get Involved
4. How to Report Issues
5. Committers and Contributors for this release
6. List of Changes in this Release


1. What is Apache Ivy?

+ +Apache Ivy is a tool for managing (recording, tracking, resolving and reporting)
project dependencies.
It is characterized by the following:

1. flexibility and configurability
Apache Ivy is essentially process agnostic and is not tied to any
methodology or structure.
Instead it provides the necessary flexibility and configurability
to be adapted to a broad range of dependency management and build
processes.
2. tight integration with Apache Ant
while available as a standalone tool, Apache Ivy works particularly well
with Apache Ant providing a number of powerful Ant tasks ranging
from dependency resolution to dependency reporting and publication.

2. Status of this release

+ +This is the first release candidate of Ivy targetting 2.2.0.

As a release candidate version, we strongly encourage the use of this version for
testing and validation. From now on, features are frozen until final 2.2.0 version,
only bug fixes may be applied before 2.2.0. If no outstanding bugs are reported
with this release candidate, it will promoted to 2.2.0 about three weeks after this
release candidate.

3. How to Get Involved

+ +The Apache Ivy project really needs and appreciates any contributions,
including documentation help, source code and feedback. If you are interested
in contributing, please visit http://ant.apache.org/ivy/get-involved.html.

4. How to Report Issues

+ +The Apache Ivy project uses JIRA for issue tracking. Please report any
issues you find at http://issues.apache.org/jira/browse/IVY

5. Committers and Contributors for this Release

Here is the list of people who have contributed source code and documentation
to this release. Many thanks to all of them, and also to the whole Ivy community
contributing ideas and feedback, and promoting the use of Ivy. The list would be too
long, but Ivy couldn't be what it is without you!

Committers
Matt Benson
Maarten Coene
Xavier Hanin
Nicolas Lalevee
Jon Schneider
Gilles Scok art

Contributors
Andreas Axelsson
Jasper Blues
Jean-Louis Boudart
Dave Brosius
Flavio Coutinho da Costa
Stefan De Boey
Gregory Fernandez
Aaron Hachez
Achim Huegen
Anders Jacobsson
Steve Jones
Heschi Kreinick
J. Lewis Muir
Carl Quinn
Michael Scheetz
Jason Trump
Richard Vowles
Sven Walter

For the list of people who have contributed since Ivy inception, see CHANGES.txt file.

6. List of Changes in this Rel ease

+ +For a full release history of Ivy see the file CHANGES.txt

For details about the following changes, check our JIRA install at
http://issues.apache.org/jira/browse/ivy

List of changes since Ivy 2.1.0:
- DOCUMENTATION: Limit the width of running text in documentation (IVY-1030)
- DOCUMENTATION: Refer to the maven wiki instead of listing some maven2 mirrors ourselfs (IVY-491)
- DOCUMENTATION: Fixed several grammatical and typographic errors in documentation (IVY-1172) (thanks to J. Lewis Muir)
- DOCUMENTATION: ivy-doc.xsl does not show configurations (IVY-1151) (thanks to Jasper Blues)
- DOCUMENTATION: Added documentation of the 'changing' attribute on the ivy:resolve Ant task (IVY-1180)

- NEW: Support ivy.xml parent mechanism (IVY-742) (thanks to Jason Trump and Jean-Louis Boudart)
- NEW: Make ivy.xml available (IVY-1158)

- IMPROVEMENT: added support for 'gzip' and 'deflate' HTTP Content-Encoding (IVY-1194)
- IMPROVEMENT: retrieve doesn't retrive files if the current one is more recent (IVY-1044)
- IMPROVEMENT: better diagnostics when reporting bad ivy file in cache (IVY-1190)
- IMPROVEMENT: Support changing="true" for inline retrieve (IVY-1180)
- IMPROVEMENT: Enhance task to access the 'publication', 'branch' and published artifacts as ant propeties (IVY-395) (thanks to Carl Quinn)
- IMPROVEMENT: Ivy doesn't support Maven 2.0.9 'import' scope (IVY-807)
- IMPROVEMENT: resolver attribute for listmodules task (IVY-1057)
- IMPROVEMENT: discover 'src' sources in maven repos (IVY-1138)
- IMPROVEMENT: Trace a message when a property file referenced from the settings doesn't exixts (IVY-1074)
- IMPROVEMENT: use defaultconf in combination with defaultconfmapping (IVY-1135) (thanks to Jon Schneider)

- FIX: The ivy-module version used by XmlModuleDescriptorWriter is hard coded to '1.0' (IVY-1199)
- FIX: makepom ignores artifact type in ivy.xml and hardcodes 'jar' in the output pom (IVY-736) (thanks to Aaron Hachez)
- FIX: Ant output wasn't always prefixed by the name of the Ivy task
- FIX: Resolved Ivy properties written to cache during ivy:resolve incorrectly represents forced re visions (IVY-1159)
- FIX: Namespace rules not properly applied to parent projects (IVY-1186)
- FIX: LatestVersionMatcher.needModuleDescriptor() does not honor custom statuses (IVY-1170) (thanks to Carl Quinn)
- FIX: Proxy authentication could fail when using commons-httpclient
- FIX: Packager resolver always extracts all files from archives even when the packaging instructions contains include tags (IVY-1179) (thanks to Stefan De Boey)
- FIX: Ivy cannot connect to URLs with '_' in their hostname
- FIX: Transitive dependencies resolutions issue when eviction is triggered (IVY-1178)
- FIX: Can't deal with [VERSION] version pattern from Maven (IVY-1177) (thanks to Richard Vowles)
- FIX: verbose/debug messages were not logged while running ivy:configure task
- FIX: ApacheURLLister does not allow directories not containing a dot on Artifactory (IVY-1175) (thanks to Anders Jacobsson)
- FIX: artifact-lock strategy could hang Ivy when resolving dynamic revisions
- FIX: Authentication won't work in some situations (IVY-1168) (thanks to Sven Walter)
- FIX: Using SFTP resolver with full pattern URL prevents use of dynamic versions (IVY-1167) (thanks to Gregory Fernande z)
- FIX: parent.groupId is not resolved in maven 2 parser (IVY-1169) (thanks to Achim Huegen)
- FIX: Creation of symlinks problematic in Windows with Cygwin 1.7 (IVY-1165)
- FIX: add ability to programmatically change default resolver (IVY-1163) (thanks to Jason Trump)
- FIX: ivy.settings.dir space escaping problem (IVY-1162)
- FIX: Ivy cannot parse alternate format for Maven MD5 files (IVY-1155)
- FIX: Ivy does not close URL connection to ivy-report.xsl properly (IVY-1152)
- FIX: Artifact report throws NPE when artifact is not in cache (IVY-1150) (thanks to Steve Jones)
- FIX: resolve fails for transitive relocated maven modules when the type of the dependency was set to 'jar'
- FIX: optional dependencies, sources and javadocs aren't resolved when a maven module is relocated
- FIX: Encountered 'multiple artifacts retrieved to same file' error when module does not have multiple artifacts (IVY-1148)
- FIX: Use of a shared DocumentBuilder causes SAXException during parallel resolutions (IVY-1147)
- FIX: metadata lock files not always deleted from cache (IVY-1145) (thanks to Jason Trump)
- FIX: FileSystem resolver with m2compatible=true throws error when publishing modules with dotted organisation names (IVY-968)
- FIX: ivy:retrieve sync="true" does nothing if first variable is optional (IVY-1142) (thanks to Andreas Axelsson)
- FIX: Latest Compatible Conflict Manager + Extra Attributes in Dependencies' IVY files == infinite loop (IVY-956)
- FIX: Resolve with Extra Attributes, Forced Dependencies causes invalid delivered ivy file (IVY-1079)
- FIX: ResolveEngine.getDependencies does not work using extra attributes (IVY-1115)
- FIX: ignored i n dynamic resolve mode (IVY-1131)
- FIX: IvyNodeEviction.cleanEvicted has bad comparison logic (IVY-1118)
- FIX: ChainResolver doesn't pass the specified 'checkmodified' attribute to the cache (IVY-1133)
- FIX: Ivy couldn't handle maven POMs that depend on theirselves
- FIX: SearchEngine.listModules returns MRID without extra attributes (IVY-1128) (thanks to Michael Scheetz)
- FIX: IvyBuildNumber non-deterministic behaviour (IVY-1120)
- FIX: Change spelling of 'occured' to 'occurred' (IVY-1123)
- FIX: Ivy deliver fails to replace dynamic revision when using extra attributes (IVY-1111) (thanks to Michael Scheetz)
- FIX: IbiblioResolver not always correctly configured when using JRE 1.5 (IVY-1124) (thanks to Flavio Coutinho da Costa)
- FIX: VstfpRepository.readResponse uses bad compare logic (IVY-1119) (thanks to Dave Brosius)
- FIX: URLResource does not properly support authentication (IVY-1106) (thanks to Heschi Kreinick)
- FIX: Excessive hits to missing URLs uses up all ports on Windows (IVY-1105)
- FIX: ivy parse exception when using (IVY-1102)
- FIX: Change org.apache to commons-cli at jdbc-example (IVY-1109)
- FIX: Fixed name snapshots are not updated even if they are marked as changing and the publication date is changed in repo (IVY-938)
- FIX: Cannot publish wildcard configurations other than * (IVY-1171)

Tutorials

The best way to learn is to practice! That's what the ivy tutorials will help you to do, to discover some of the great ivy features.

Here is the very first tutorial, it doesn't even require to install Ivy, and should not take more than 30 seconds if you already have ant and a jdk properly installed: +
    +
  • make sure you have ant 1.6.0 or greater and a jdk properly installed
  • +
  • copy this build file in an empty directory on your local filesystem (and make sure you name it build.xml)
  • +
  • open a console in this directory and run "ant". That's it!
  • +
+If you have any trouble, check the FAQ, it may be related to your internet connection (proxy anyone?).

OK, you've seen how easy it is to make your first step with ivy? Go ahead with the other tutorials, but before make sure you have properly installed ivy and downloaded the tutorials sources (included in all ivy distributions, in the src/example directory).

The following tutorials are available: + +
Quick Start

In this example, we will see one of the easiest way to use Ivy. With no specific settings, Ivy uses the maven 2 repository to resolve the dependencies you declare in an Ivy file. Let's have a look at the content of the files involved.

You'll find this tutorial's sources in the ivy distribution in the src/example/hello-ivy directory.

The ivy.xml file

+This file is used to describe the dependencies of the project on other libraries.
Here is the sample: +
+<ivy-module version="2.0">
<info organisation="org.apache" module="hello-ivy"/>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.0"/>
<dependency org="commons-cli" name="commons-cli" rev="1.0"/>
</dependencies>
</ivy-module> +
+ +The format of this file should pretty easy to understand, but let's give some details about what is declared here. First, the root element ivy-module, with the version attribute used to tell Ivy which version of Ivy this file use.

Then there is an info tag, which is used to give information about the module for which we are defining dependencies. Here we define only the organization and module name, you are free to choose whatever you want for them, but we recommend avoiding spaces for both of them.

Finally, the dependencies section let you define dependencies. Here this module depends on two libraries: commons-lang and commons-cli. As you can see we use the org and name attribute to define the organization and module name of the dependencies we need. The rev attribute is used to specify the revision of the module you depend on.

To know what to p ut in these attributes, you need to know the exact information for the libraries you depend on. Ivy uses the maven 2 repository by default. We recommend you use mvnrepository.com to look for the module you want. Once you find it, you will have the details on how to declare the dependency in a maven POM. For instance: +
+<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.0</version>
</dependency> +
+To convert this into an Ivy dependency declaration, all you have to do is use the groupId as organization, the artifactId as module name, and the version as revision. That's what we did for the dependencies in this tutorial, that is commons-lang and commons-cli. Note that having commons-lang and commons-cli as organization is not the best example of what the organization should be. It would be better to use org.apache, org.apache.commons or org.apache.commons.lang. However, this is how these modules are identified in the maven 2 repository, so the simplest way to get them is to use the details as is (you will see in Building a repository that you can use namespaces to redefine these names if you want something cleaner).

If you want more details on what you can do in Ivy files, you can have a look at the Ivy files reference documentation.

The build.xml file

+The corresponding build file contains a set of targets, allowing to resolve dependencies declared in the Ivy file, to compile and run the sample code, produce a report of dependency resolution, and clean the cache or the project.
You can use the standard "ant -p" to get the list of available targets. Feel free to have a look at the whole file, but here is the part relevant to dependency resolution: +
+<project xmlns:ivy="antlib:org.apache.ivy.ant" name="hello-ivy" default="run">

...

<!-- =================================
target: resolve
================================= -->
<target name="resolve" description="--> retrieve dependencies with ivy">
<ivy:retrieve />
</target>
</project> +
+As you can see, it's very easy to call Ivy to resolve and retrieve dependencies: all you need if Ivy is properly installed is to define an XML namespace in your Ant file (xmlns:ivy="antlib:org.apache.ivy.ant"). Then all the Ivy ant tasks will be available in this namespace.

Here we use only one task: the retrieve task. With no attributes, it will use default settings and look for a file named ivy.xml for dependency definition. That's exactly what we want, so we need nothing more than that.

Note that in this case we define a "resolve" target and call the retrieve task. This may sound confusing, actually the retrieve task performs a resolve (which resolves dependencies and downloads them to a cache) followed by a retrieve (a copy of those file in a l ocal project directory). Check the How does it work ? page for details about that.

Running the project

+Ok, now that we have seen the files involved, let's run the sample to see what happens. Open a shell (or command line) window, and enter the hello-ivy example directory.
Then, at the command prompt, run 'ant': +
+[ivy@apache:/ivy/hello-ivy]$ ant 
+Buildfile: /ivy/hello-ivy/build.xml
+
+resolve:
+[ivy:retrieve] :: Ivy 2.2.0-rc1 - 20100629224905 :: http://ant.apache.org/ivy/ ::
+[ivy:retrieve] :: loading settings :: url = jar:file:///home/ivy/ivy.jar!/org/apache/ivy/core/settings/ivysettings.xml
+[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working@apache
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	found commons-lang#commons-lang;2.0 in public
+[ivy:retrieve] 	found commons-cli#commons-cli;1.0 in public
+[ivy:retrieve] 	found commons-logging#commons-logging;1.0 in public
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0-javadoc.jar ...
+[ivy:retrieve] .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
+[ivy:retrieve] ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ (467kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar(javadoc) (4056ms)
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0-sources.jar ...
+[ivy:retrieve] ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ (245kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar(source) (2621ms)
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0.jar ...
+[ivy:retrieve] ........................................................................................................................................................................................................................................................................................................................................... (165kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar (1809ms)
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0.jar ...
+[ivy:retrieve] ........................................................ (29kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-cli#commons-cli;1.0!commons-cli.jar (1638ms)
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0-javadoc.jar ...
+[ivy:retrieve] ............................................................................................................................................................................................. (92kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-cli#commons-cli;1.0!commons-cli.jar(javadoc) (2403ms)
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0-sources.jar ...
+[ivy:retrieve] ...................................................................................................... (48kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-cli#commons-cli;1.0!commons-cli.jar(source) (2106ms)
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-logging/commons-logging/1.0/commons-logging-1.0.jar ...
+[ivy:retrieve] ........................................... (21kB)
+[ivy:retrieve] ... (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-logging#commons-logging;1.0!commons-logging.jar (1825ms)
+[ivy:retrieve] :: resolution report :: resolve 9314ms :: artifacts dl 16520ms
+[ivy:retrieve] 	:: evicted modules:
+[ivy:retrieve] 	commons-lang#commons-lang;1.0 by [commons-lang#commons-lang;2.0] in [default]
+	---------------------------------------------------------------------
+	|                  |            modules            ||   artifacts   |
+	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
+	---------------------------------------------------------------------
+	|      default     |   4   |   3   |   3   |   1   ||   7   |   7   |
+	---------------------------------------------------------------------
+[ivy:retrieve] :: retrieving :: org.apache#hello-ivy
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	7 artifacts copied, 0 already retrieved (1069kB/62ms)
+
+run:
+    [mkdir] Created dir: /ivy/hello-ivy/build
+    [javac] /ivy/hello-ivy/build.xml:53: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
+    [javac] Compiling 1 source file to /ivy/hello-ivy/build
+     [java] standard message : hello ivy !
+     [java] capitalized by org.apache.commons.lang.WordUtils : Hello Ivy !
+
+BUILD SUCCESSFUL
+Total time: 28 seconds
+
+
+

What happened ?

+Without any settings, Ivy retrieves files from the maven 2 repository. That's what happened here.
The resolve task has found the commons-lang and commons-cli modules in the maven 2 repository, identified that commons-cli depends on commons-logging and so resolved it as a transitive dependency. Then Ivy has downloaded all corresponding artifacts in its cache (by default in your user home, in a .ivy2/cache directory). Finally, the retrieve task copies the resolved jars from the ivy cache to the default library directory of the project: the lib dir (you can change this easily by setting the pattern attribute on the retrieve task).

You might say that the task took a long time just to write out a "Hello Ivy !" message. But remember that a lot of time was spent downloading the required files from the web. Let's try to run it again: +
+[ivy@apache:/ivy/hello-ivy]$ ant 
+Buildfile: /ivy/hello-ivy/build.xml
+
+resolve:
+[ivy:retrieve] :: Ivy 2.2.0-rc1 - 20100629224905 :: http://ant.apache.org/ivy/ ::
+[ivy:retrieve] :: loading settings :: url = jar:file:///home/ivy/ivy.jar!/org/apache/ivy/core/settings/ivysettings.xml
+[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working@apache
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	found commons-lang#commons-lang;2.0 in public
+[ivy:retrieve] 	found commons-cli#commons-cli;1.0 in public
+[ivy:retrieve] 	found commons-logging#commons-logging;1.0 in public
+[ivy:retrieve] :: resolution report :: resolve 203ms :: artifacts dl 16ms
+[ivy:retrieve] 	:: evicted modules:
+[ivy:retrieve] 	commons-lang#commons-lang;1.0 by [commons-lang#commons-lang;2.0] in [default]
+	---------------------------------------------------------------------
+	|                  |            modules            ||   artifacts   |
+	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
+	---------------------------------------------------------------------
+	|      default     |   4   |   0   |   0   |   1   ||   7   |   0   |
+	---------------------------------------------------------------------
+[ivy:retrieve] :: retrieving :: org.apache#hello-ivy
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	0 artifacts copied, 7 already retrieved (0kB/0ms)
+
+run:
+    [javac] /ivy/hello-ivy/build.xml:53: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
+     [java] standard message : hello ivy !
+     [java] capitalized by org.apache.commons.lang.WordUtils : Hello Ivy !
+
+BUILD SUCCESSFUL
+Total time: 1 second
+
+
+Great! the cache was used, no download was needed and the build was instantaneous.

And now, if you want to generate a report detailing all the dependencies of your module, you can call the report target, and check the generated file in the build directory. You should obtain something looking like this.

As you can see, using Ivy to resolve dependencies stored in the maven 2 repository is extremely easy. Now you can go on with the next tutorials to learn more about how to use module configurations which is a very powerful Ivy specific feature. Other tutorials are also available where you will learn how to use Ivy settings to leverage a possibly complex enterprise repository. It may also be a good time to start reading the reference documentation, and especially the introduction material which gives a good overview of Ivy. The best practices page is also a must read to start thinking about how to use Ant+Ivy to build a clean and robust build system.
Adjusting default settings

Ivy comes bundled with some default settings which makes it pretty simple to use in common environment. This tutorial, which is close to a reference documentation, explains what are those default settings and how they can be adjusted to your needs.

To fully understand the concept of settings and what you can do with them, we suggest reading other tutorial related to settings (like Multiple Resolvers and Dual Resolver) or the Settings Files reference documentation.

Concept

+This default settings mainly consist of 3 kind of repositories: +
    +
  • local
  • a repository which is private to the user. +
  • shared
  • a repository which is shared between all the member of a team +
  • public
  • a public repository on which most modules, and especially third party modules, can be found +
+ +Note that if you work alone, the distinction between local and shared repository is not very important, but there are some things to know to distinguish them.

Now let's describe each of these repositories concept in more details. We will describe how they are setup physically later.

Local

+The local repository is particularly useful when you want to do something without being disturbed by anything else happening in the environment. This means that whenever ivy is able to locate a module in this repository it will be used, no matter of what is available in others.

For instance, if you have a module declaring a dependency on the module foo in revision latest.integration, then if a revision of foo is found in the local repository, it will be used, even if a more recent revision is available in other repositories.

This may be disturbing for some of you, but imagine you have to implement a new feature on a project, and in order to achieve that you need to modify two modules: you add a new method in module foo and exploit this new method in module bar. Then if you publish the module foo to your local repository, you will be sure to get it in your bar module, even if someo ne else publish a new revision of foo in the shared repository (this revision not having the new method you are currently adding).

But be careful, when you have finished your development and publish it on the shared you will have to clean your local repository to benefit from new versions published in the shared repository.

Note also that modules found in the local repository must be complete, i.e. they must provide both a module descriptor and the published artifacts.

Shared

+As its name suggest, the shared repository is aimed to be shared among a whole development team. It is a place where you can publish your team private modules for instance, and it's also a place where you can put modules not available in the public repository (sun jars, for instance), or simply not accurate (bad or incomplete module descriptors for instance).

Note that modules can be split across the shared repository and the public one: you can have the module descriptor in the shared repository and the artifacts in the public one, for instance.

Public

+The public repository is the place where most modules can be found, but which sometimes lack the information you need. It's usually a repository available through an internet connection only, even if this is not mandatory.

Setting up the repositories

+Now that we have seen the objective of each of the three repositories, let's see how they are setup and how to configure them to fit your needs.

First, several repositories uses the same root in your filesystem. Referenced as ${ivy.default.ivy.user.dir}, this is by default the directory .ivy2 in your user home.

Note that several things can be done by setting ivy variable. To set them without defining your own ivysettings.xml file, you can:
    +
  • set an ant property before any call to ivy in your build file if you use ivy from ant
  • +
  • set an environment variable if you use ivy from the command line
  • +
+For instance: +
+<target name="resolve">
<property name="ivy.default.ivy.user.dir" value="/path/to/ivy/user/dir"/>
<ivy:resolve />
</target> +
+ +Now we will show how to override default values for the different kind of repositories, note that you can find what are these default values below in the detail of the default settings.

Local

+By default, the local repository lies in ${ivy.default.ivy.user.dir}/local. This is usually a good place, but you may want to modify it however. No problem, you just have to set the following ivy variable to the directory you want to use:
ivy.local.default.root
. For instance: +
ivy.local.default.root=/opt/ivy/repository/local
.

If you already have something you would like to use as your local repository, you may also want to modify the layout of this repository. Once again, two variables are available for that: +
ivy.local.default.ivy.pattern
gives the pattern to find ivy files +
ivy.local.default.artifact.pattern
gives the pattern to find artifacts
For example: +
+ivy.local.default.root=/opt/ivy/repository/local
ivy.local.default.ivy.pattern=[module]/[revision]/ivy.xml
ivy.local.default.artifact.pattern=[module]/[revision]/[artifact].[ext] +
+

Shared

+By default, the shared repository lies in ${ivy.default.ivy.user.dir}/shared. This is fine if you work alone, but the shared repository is supposed to be, mmm, shared! So changing this directory is often required, and it is usually modified to point to a network shared directory. You can use
ivy.shared.default.root
variable to specify in a new directory. Moreover, you can also configure the layout with variables similar to the one for the local repository: +
ivy.shared.default.ivy.pattern
gives the pattern to find ivy files +
ivy.shared.default.artifact.pattern
gives the pattern to find artifacts
For example: +
+ivy.shared.default.root=/opt/ivy/repository/shared
ivy.shared.default.ivy.pattern=[organisation]/[module]/[revision]/ivy.xml
ivy.shared.default.artifact.pattern=[organisation]/[module]/[revision]/[artifact].[ext] +
+ +

Public

+By default, the public repository is ibiblio in m2 compatible mode (in other words, the maven 2 public repository).

This repository has the advantage of providing a lot of modules, with metadata for most of them. The quality of metadata is not always perfect, but it's a very good start to use a tool like Ivy and benefit from the power of transitive dependency management.

Despite its ease of use, we suggest reading the Best practices to have a good understanding of the pros and cons of using a public unmanaged repository before depending on such a repository for your enterprise build system.

In 1.4 version Ivy was using ivyrep has default resolver, if you want to restore this, set
ivy.14.compatible=true as an ant property


Going further

+OK, so we have seen how to easily change the settings of the three main repositories. But what if my shared repository is on a web server? What if you don't want to use maven 2 repository as public repository? What if ...

No problem, Ivy is very flexible and can be configured with very specific settings to match your needs and environment. But before considering writing your own settings from scratch, we suggest reading the following where you will learn how to leverage a part of the default settings and adjust the rest.

But before explaining how, you will need to have a quick overview of how ivy is configured by default.

By default, ivy is configured using an ivysettings.xml which is packaged in the ivy jar. Here is this settings file: +
+<ivysettings>
<settings defaultResolver="default"/>
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
</ivysettings> +
+OK, so not much info here, except a lot of inclusions. These inclusions have been done on purpose so that you can easily change only one part of the ivysettings and benefit of the rest easily. For example, if you want to define your own public resolver, you will just have to configure ivy with an ivysettings like that: +
+<ivysettings>
<settings defaultResolver="default"/>
<include url="http://myserver/ivy/myivysettings-public.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
</ivysettings> +
+Note that only the ivysettings-public inclusion has changed to include a home made public resolver. Note also that this can be used like that thanks to the fact that ${ivy.default.settings.dir} is a variable which is always set to the place where ivy default settings files are (i.e. packaged in the jar).
To finish this example, you have to write your own ivysettings file (that you will make available at http://myserver/ivy/myivysettings-public.xml in this example) for defining your own public resolver. For instance: +
+<ivysettings>
<resolvers>
<filesystem name="public">
<ivy pattern="/path/to/my/public/rep/[organisation]/[module]/ivy-[revision].xml" />
<artifact pattern="/path/to/my/public/rep/[organisation]/[module]/[artifact]-[revision].[ext]" />
</filesystem>
</resolvers>
</ivysettings> +
+Now the last thing you will need in order to properly take advantage of the default settings is the content of each included ivysettings file:
ivysettings-public.xml +
+<ivysettings>
<resolvers>
<ibiblio name="public" m2compatible="true"/>
</resolvers>
</ivysettings> +
+ivysettings-shared.xml +
+<ivysettings>
<property name="ivy.shared.default.root" value="${ivy.default.ivy.user.dir}/shared" override="false"/>
<property name="ivy.shared.default.ivy.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>
<property name="ivy.shared.default.artifact.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>
<resolvers>
<filesystem name="shared">
<ivy pattern="${ivy.shared.default.root}/${ivy.shared.default.ivy.pattern}" />
<artifact pattern="${ivy.shared.default.root}/${ivy.shared.default.artifact.pattern}" />
</filesystem>
</resolvers>
</ivysettings> +
+ivysettings-local.xml +
+<ivysettings>
<property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local" override="false"/>
<property name="ivy.local.default.ivy.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>
<property name="ivy.local.default.artifact.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false"/>
<resolvers>
<filesystem name="local">
<ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" />
<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
</filesystem>
</resolvers>
</ivysettings> +
+ivysettings-main-chain.xml +
+<ivysettings>
<resolvers>
<chain name="main" dual="true">
<resolver ref="shared"/>
<resolver ref="public"/>
</chain>
</resolvers>
</ivysettings> +
+ivysettings-default-chain.xml +
+<ivysettings>
<resolvers>
<chain name="default" returnFirst="true">
<resolver ref="local"/>
<resolver ref="main"/>
</chain>
</resolvers>
</ivysettings> +
+ +Here you are, you have enough clues to configure that the way you want... check the settings documentation to see if what you want to do is possible, and go ahead!

Multiple Resolvers

This example is an illustration of how modules can be retrieved by multiple resolvers. Using multiple resolvers can be useful in many contexts, here are some examples: +
    +
  • separate integration builds from releases
  • +
  • use a public repository for third party modules and a private one for internal modules
  • +
  • use a repository for storing modules which are not accurate in an unmanaged public repository
  • +
  • use a local repository to expose builds made on one developer's station
  • +
+ +In Ivy, the use of multiple resolvers is supported by one compound resolver called a chain resolver.

In our example, we will simply show how to use two resolvers, one on a local repository and one using maven2 repository.

project description

+

the project: chained-resolvers

+The project is very simple and contains only one simple class: example.Hello.

It 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
  • +
+Let's have a look at the ivy.xml file: +
+<ivy-module version="1.0">
<info organisation="org.apache" module="chained-resolvers"/>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.0"/>
<dependency name="test" rev="1.0"/>
</dependencies>
</ivy-module> +
+As we expect, the ivy file declares to be dependent on the two libraries that the project use: commons-lang and test. Note that we don't specify the organisation for the dependency test, in this case Ivy assumes the same org as the declaring module, ie org.apache in this case.

the ivy settings

+The ivy settings is made in the settings directory it contains only one file: ivysettings.xml.
+
+<ivysettings>
<settings defaultResolver="chain-example"/>
<resolvers>
<chain name="chain-example">
<filesystem name="libraries">
<artifact pattern="${ivy.settings.dir}/repository/[artifact]-[revision].[ext]" />
</filesystem>
<ibiblio name="ibiblio" m2compatible="true" />
</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.
  • +
+ +That's it, we have configured a chain of resolvers!

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: ant
+This will clean up the entire project directory tree and ivy cache. You can do it each time you want to clean up this example.
+
+In almost all examples, we provide a clean target as default target. Since most examples use the same Ivy cache, you will clean the whole Ivy cache each time you call this target.

Cleaning Ivy cache is something you can do with no fear (except performance): it's only a cache, everything can be (and should be) obtained again from repositories. For those coming from maven 2 land, this may sounds strange, but remember that in Ivy, the cache is not a local repository, things are kept cleanly isolated. +
+
+
+

step 3: run the project

+Go to chainedresolvers-project directory. And simply run ant.
+
+[ivy@apache:/ivy/chained-resolvers/chainedresolvers-project]$ ant 
+Buildfile: /ivy/chained-resolvers/chainedresolvers-project/build.xml
+
+resolve:
+[ivy:retrieve] :: Ivy 2.2.0-rc1 - 20100629224905 :: http://ant.apache.org/ivy/ ::
+[ivy:retrieve] :: loading settings :: file = /ivy/chained-resolvers/settings/ivysettings.xml
+[ivy:retrieve] :: resolving dependencies :: org.apache#chained-resolvers;working@apache
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	found commons-lang#commons-lang;2.0 in ibiblio
+[ivy:retrieve] 	found org.apache#test;1.0 in libraries
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0.jar ...
+[ivy:retrieve] .......................................................................................................................................................................................................................................................................................................................
+[ivy:retrieve] ............. (165kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar (3495ms)
+[ivy:retrieve] downloading /ivy/chained-resolvers/settings/repository/test-1.0.jar ...
+[ivy:retrieve] .. (1kB)
+[ivy:retrieve] 	[SUCCESSFUL ] org.apache#test;1.0!test.jar (15ms)
+[ivy:retrieve] :: resolution report :: resolve 4181ms :: artifacts dl 3510ms
+	---------------------------------------------------------------------
+	|                  |            modules            ||   artifacts   |
+	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
+	---------------------------------------------------------------------
+	|      default     |   2   |   2   |   1   |   0   ||   2   |   2   |
+	---------------------------------------------------------------------
+[ivy:retrieve] :: retrieving :: org.apache#chained-resolvers
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	2 artifacts copied, 0 already retrieved (166kB/31ms)
+
+run:
+    [mkdir] Created dir: /ivy/chained-resolvers/chainedresolvers-project/build
+    [javac] /ivy/chained-resolvers/chainedresolvers-project/build.xml:58: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
+    [javac] Compiling 1 source file to /ivy/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: 11 seconds
+
+
+ +We can see in the log of the resolve task, that the two dependencies have been retrieved (2 artifacts) and copied to the ivy cache directory (2 downloaded).

The run target succeed in using both commons-lang.jar comming from ibiblio repository and test.jar coming from the local repository.

Going further

+This very simple example helps to see how to make a basic setting of two resolvers in a chain. The chain resolver's reference documentation is available for those who would like to know all the features offered by this resolver.

The most interesting things to know that you can try out from this basic example are: +
    +
  • a chain is not limited to two nested resolvers, you can use the number you want
  • +
  • by setting returnFirst="true", you can have a chain which stops as soon as it has found a result for a given module
  • +
  • by setting dual="true", the full chain will be used both for module descriptors and artifacts, while with dual="false", the resolver in the chain which found the module descriptor (if any) is also used for artifacts
  • +
+ +
Dual Resolver

In some cases it may happen that your module descriptors (Ivy files, maven pom, ...) are located at one place and module artifacts (jars, ...) at another place.

Dual Resolver is used to address this kind of need, and this tutorial will show how to use it.

project description

+Let's have a look at the src/example/dual directory in your ivy distribution.
It contains a build file and 3 directories: +
    +
  • settings: contains the ivy settings file
  • +
  • repository: a sample repository of ivy files
  • +
  • project: the project making use of ivy with dual resolver
  • +
+ +

the dual project

+The project is very simple and contains only one simple class: example.Hello
It depends on two libraries: Apache commons-lang and Apache commons-httpclient.

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
  • +
+ +Let's have a look at the ivy.xml file: +
+<ivy-module version="1.0">
<info organisation="org.apache" module="hello-ivy"/>
<dependencies>
<dependency org="commons-httpclient" name="commons-httpclient" rev="2.0.2"/>
<dependency org="commons-lang" name="commons-lang" rev="2.0"/>
</dependencies>
</ivy-module> +
+ +As you can see, nothing special here... Indeed, it's the philosophy of ivy to keep ivy files independent of the way dependencies are resolved.

the ivy settings

+The ivy settings is made in the settings directory; it contains only one file: ivysettings.xml.
+
+<ivysettings>
<settings defaultResolver="dual-example"/>
<resolvers>
<dual name="dual-example">
<filesystem name="ivys">
<ivy pattern="${ivy.settings.dir}/../repository/[module]-ivy-[revision].xml" />
</filesystem>
<ibiblio name="ibiblio" m2compatible="true" usepoms="false" />
</dual>
</resolvers>
</ivysettings> +
+ +Here we configure one resolver, the default one, which is a dual resolver. This dual resolver has two sub resolvers: the first is what is called the "ivy" or "metadata" resolver of the dual resolver, and the second one is what is called the "artifact" resolver. It is important that the dual resolver exactly has two sub resolvers in this given order.
The metadata resolver, here a filesystem one, is used only to find module descriptors, in this case Ivy files. The settings given in this resolver says that all ivy files are in the same directory, named like that: [module]-ivy-[revision].xml. If we check the repository directory, we can confirm that it contains a file named commons-httpclient-ivy-2.0.2.xml. It fulfills the given pattern and will thus be found by this resolver.
The artifact resolver is simply an ibiblio one, configured in m2compatible mode to use the maven 2 repository, with usepoms="false" to make sure it won't use maven 2 metadata. Note that this isn't strictly necessary, since the second resolver in a dual resolver (the artifact resolver) is never asked to find module metadata.

walkthrough

+
+

step 1 : preparation

+Open a DOS or shell window, and go to the "dual" directory. +
+
+

step 2 : clean up

+On the prompt type : ant
+This will clean up the entire project directory tree (compiled classes and retrieved libs) and ivy cache.
You can do it each time you want to clean up this example. +
+
+

step 3 : run the project

+Goto project directory. And simply run ant. +
+[ivy@apache:/ivy/dual/project]$ ant 
+Buildfile: /ivy/dual/project/build.xml
+
+resolve:
+[ivy:retrieve] :: Ivy 2.2.0-rc1 - 20100629224905 :: http://ant.apache.org/ivy/ ::
+[ivy:retrieve] :: loading settings :: file = /ivy/dual/settings/ivysettings.xml
+[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working@apache
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	found commons-httpclient#commons-httpclient;2.0.2 in ivys
+[ivy:retrieve] 	found commons-logging#commons-logging;1.0.4 in ibiblio
+[ivy:retrieve] 	found commons-lang#commons-lang;2.0 in ibiblio
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar ...
+[ivy:retrieve] ......................................................................................................................................................................................................................................................................................................................................................................................................................................................... (220kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-httpclient#commons-httpclient;2.0.2!commons-httpclient.jar (3557ms)
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0.jar ...
+[ivy:retrieve] ................................................................................................................................................................................................................................................................................................................................................. (165kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar (2418ms)
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar ...
+[ivy:retrieve] ......................................................................... (37kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-logging#commons-logging;1.0.4!commons-logging.jar (1794ms)
+[ivy:retrieve] :: resolution report :: resolve 889ms :: artifacts dl 7769ms
+	---------------------------------------------------------------------
+	|                  |            modules            ||   artifacts   |
+	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
+	---------------------------------------------------------------------
+	|      default     |   3   |   3   |   1   |   0   ||   3   |   3   |
+	---------------------------------------------------------------------
+[ivy:retrieve] :: retrieving :: org.apache#hello-ivy
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	3 artifacts copied, 0 already retrieved (423kB/47ms)
+
+run:
+    [mkdir] Created dir: /ivy/dual/project/build
+    [javac] /ivy/dual/project/build.xml:58: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
+    [javac] Compiling 1 source file to /ivy/dual/project/build
+     [java] standard message : hello ivy !
+     [java] capitalized by org.apache.commons.lang.WordUtils : Hello Ivy !
+     [java] head status code with httpclient: 200
+     [java] now check if httpclient dependency on commons-logging has been realized
+     [java] found logging class in classpath: interface org.apache.commons.logging.Log
+
+BUILD SUCCESSFUL
+Total time: 11 seconds
+
+
+
+As you can see, ivy not only downloaded commons-lang and commons-httpclient, but also commons-logging. Indeed, commons-logging is a dependency of httpclient, as we can see in the httpclient ivy file found in the repository directory: +
+<ivy-module version="1.0">
<info
organisation="commons-httpclient"
module="commons-httpclient"
revision="2.0.2"
status="release"
publication="20041010174300"/>
<dependencies>
<dependency org="commons-logging" name="commons-logging" rev="1.0.4" conf="default"/>
</dependencies>
</ivy-module> +
+
+So everything worked well, ivy file has been found in the repository directory and artifacts have been downloaded from ibiblio.

This kind of setup can be useful if you don't want to rely on maven 2 repository for metadata, or if you want to take full advantage of Ivy files for some or all modules. Combining chain and dual resolvers can lead to very flexible settings addressing most needs.

For full details about the dual resolver, have a look at the corresponding reference documentation.

Project dependencies

This example is an illustration of dependency between two projects.

The depender project declares that it uses the dependee one. We will illustrate two things: +
    +
  • public libraries declared by standalone project will automatically be retrieved by the dependant project
  • +
  • the depender project will retrieve the "latest" version of the dependee project
  • +
+

projects used

+

dependee

+The dependee project is very simple. It depends on the apache library commons-lang and contains only one class: standalone.Main which provides two services: +
    +
  • return the version of the project
  • +
  • capitalize a string using org.apache.commons.lang.WordUtils.capitalizeFully
  • +
+Here is the content of the project: +
    +
  • build.xml: the ant build file for the project
  • +
  • ivy.xml: the project ivy file
  • +
  • src\standalone\Main.java: the only class of the project
  • +
+Take a look at the ivy.xml file: +
+<ivy-module version="1.0">
<info organisation="org.apache" module="dependee"/>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.0"/>
</dependencies>
</ivy-module> +
+ +The ivy dependency file declares only one dependency on apache commons-lang library.

depender

+The project depender is very simple too. It declares only one dependency on the latest version of the dependee project and it contains only one class depending.Main which make 2 things: +
    +
  • getting the version of the standalone project throw a call to standalone.Main.getVersion()
  • +
  • transform a string throw a call to standalone.Main.capitalizeWords(str)
  • +
+Take a look at the ivy.xml file: +
+<ivy-module version="1.0">
<info organisation="org.apache" module="depender"/>
<dependencies>
<dependency name="dependee" rev="latest.integration" />
</dependencies>
</ivy-module> +
+ +

settings

+The ivy settings is made in the settings directory which contains 2 files: +
    +
  • ivysettings.properties: a property file
  • +
  • ivysettings.xml: the file containing the settings
  • +
+ +Let's have a look at the ivysettings.xml file: +
+<ivysettings>
<properties file="${ivy.settings.dir}/ivysettings.properties"/>
<settings defaultCache="${ivy.settings.dir}/ivy-cache" defaultResolver="libraries"/>
<resolvers>
<filesystem name="projects">
<artifact pattern="${repository.dir}/[artifact]-[revision].[ext]" />
<ivy pattern="${repository.dir}/[module]-[revision].xml" />
</filesystem>
<ibiblio name="libraries" m2compatible="true" usepoms="false" />
</resolvers>
<modules>
<module organisation="org.apache" name="dependee" resolver="projects"/>
</modules>
</ivysettings> +
+The file contains four main tags: properties, settings, resolvers and modules.

properties

+This tag only load some properties for the ivy process in the same manner as ant would do it.

settings

+This tag is in charge of initializing some parameters for ivy process. The directory that ivy will use to cache artifacts will be in a sub directory called ivy-cache of the directory containing the ivysettings.xml file itself.
The second parameter, tells ivy to use a resolver called "libraries" as its default resolver. More information can be found in the settings reference documentation.

resolvers

+This tag defines the resolvers to use. Here we have two resolvers defined: "projects" and "libraries".
The filesystem resolver called "projects" is able to resolve the internal dependencies by locating them on the local filesystem.
The ibiblio resolver called "libraries" is able to find dependencies on maven 2 repository, but doesn't use maven poms.

modules

+The modules tag allows to configure which resolver should be used for which module. Here the settings only tells to use the "projects" resolver for all modules having for organisation "org.apache" and for module name "dependee". This actually corresponds to only one module, but a regular expression could be used, or many other kind of expressions (like glob expressions).

For other modules (i.e. all modules but org.apache#dependee), since there is no special settings, the default resolver will be used: "libraries".

walkthrough

+
+

step 1: preparation

+Open a DOS or shell window, and go to the "src/example/dependence" directory. +
+
+

step 2: clean directory tree

+On the prompt type: ant
This will clean up the entire project directory tree. You can do it each time you want to clean up this example. +
+
+

step 3: publication of dependee project

+Go to dependee directory and publish the project +
+[ivy@apache:/ivy/dependence/dependee]$ ant publish
+Buildfile: /ivy/dependence/dependee/build.xml
+
+resolve:
+[ivy:retrieve] :: Ivy 2.2.0-rc1 - 20100629224905 :: http://ant.apache.org/ivy/ ::
+[ivy:retrieve] :: loading settings :: file = /ivy/dependence/settings/ivysettings.xml
+[ivy:retrieve] DEPRECATED: 'defaultCache' is deprecated, use 'caches[@defaultCacheDir]' instead (file://ivy/dependence/settings/ivysettings.xml)
+[ivy:retrieve] :: resolving dependencies :: org.apache#dependee;working@apache
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	found commons-lang#commons-lang;2.0 in libraries
+[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0.jar ...
+[ivy:retrieve] ........................................................................................................................................................................................................................................................................................................................................... (165kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar (2465ms)
+[ivy:retrieve] :: resolution report :: resolve 452ms :: artifacts dl 2465ms
+	---------------------------------------------------------------------
+	|                  |            modules            ||   artifacts   |
+	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
+	---------------------------------------------------------------------
+	|      default     |   1   |   1   |   0   |   0   ||   1   |   1   |
+	---------------------------------------------------------------------
+[ivy:retrieve] :: retrieving :: org.apache#dependee
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	1 artifacts copied, 0 already retrieved (165kB/15ms)
+
+compile:
+    [mkdir] Created dir: /ivy/dependence/dependee/build/classes
+    [javac] /ivy/dependence/dependee/build.xml:60: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
+    [javac] Compiling 1 source file to /ivy/dependence/dependee/build/classes
+
+jar:
+[propertyfile] Creating new property file: /ivy/dependence/dependee/build/classes/version.properties
+      [jar] Building jar: /ivy/dependence/dependee/build/dependee.jar
+
+publish:
+[ivy:publish] :: delivering :: org.apache#dependee;working@apache :: 1 :: release :: Tue Jun 29 22:58:14 CEST 2010
+[ivy:publish] 	delivering ivy file to /ivy/dependence/dependee/build/ivy.xml
+[ivy:publish] :: publishing :: org.apache#dependee
+[ivy:publish] 	published dependee to /ivy/dependence/settings/repository/dependee-1.jar
+[ivy:publish] 	published ivy to /ivy/dependence/settings/repository/dependee-1.xml
+     [echo] project dependee released with version 1
+
+BUILD SUCCESSFUL
+Total time: 5 seconds
+
+
+What we see here: +
    +
  • the project depends on 1 library (1 artifact)
  • +
  • the library was not in the ivy cache and so was downloaded (1 downloaded)
  • +
  • the project has been released under version number 1
  • +
+
+To give more details on the publish, as you can see the call to the publish task has resulted in two main things: +
    +
  • the delivery of a resolved ivy file to build/ivy.xml.
  • +This has been done because by default the publish task not only publishes artifacts but also ivy file. So it has looked to the path where the ivy file to publish should be, using the artifactspattern: ${build.dir}/[artifact].[ext].
    For an ivy file, this resolves to build/ivy.xml. Because this file does not exist, it automatically makes a call to the deliver task which delivers a resolved ivy file to this destination. +
  • the publication of artifact dependee and resolved ivy file to the repository.
  • +Both are mere copy of files found in the current project, more precisely in the build dir. This is because the artifactspattern has been set to ${build.dir}/[artifact].[ext], so dependee artifact is found in build/dependee.jar and ivy file in build/ivy.xml. And because we have asked the publish task to publish them using the "projects" resolver, these files are copied to repository\dependee-1.jar and to repository\dependee-1.xml, respecting the artifact and ivy patterns of our settings (see above). +
+ +
+

step 4: running the depender project

+Go to directory depender and run ant +
+[ivy@apache:/ivy/dependence/depender]$ ant 
+Buildfile: /ivy/dependence/depender/build.xml
+
+clean:
+
+resolve:
+[ivy:retrieve] :: Ivy 2.2.0-rc1 - 20100629224905 :: http://ant.apache.org/ivy/ ::
+[ivy:retrieve] :: loading settings :: file = /ivy/dependence/settings/ivysettings.xml
+[ivy:retrieve] DEPRECATED: 'defaultCache' is deprecated, use 'caches[@defaultCacheDir]' instead (file://ivy/dependence/settings/ivysettings.xml)
+[ivy:retrieve] :: resolving dependencies :: org.apache#depender;working@apache
+[ivy:retrieve] 	confs: [default]
+[ivy:retrieve] 	found org.apache#dependee;1 in projects
+[ivy:retrieve] 	[1] org.apache#dependee;latest.integration
+[ivy:retrieve] 	found commons-lang#commons-lang;2.0 in libraries
+[ivy:retrieve] downloading /ivy/dependence/settings/repository/dependee-1.jar ...
+[ivy:retrieve] .. (1kB)
+[ivy:retrieve] .. (0kB)
+[ivy:retrieve] 	[SUCCESSFUL ] org.apache#dependee;1!dependee.jar (16ms)
+[ivy:retrieve] :: resolution report :: resolve 343ms :: artifacts dl 16ms
+	---------------------------------------------------------------------
+	|                  |            modules            ||   artifacts   |
+	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|

[... 5179 lines stripped ...]