(since 2.0) The settings declaration is used to configure ivy with an xml settings file. The difference with the configure task is that when using the settings declaration, the configuration of Ivy will be done when the settings are first needed (for instance when you do a resolve), while the configure task will perform a configuration of Ivy instantly, which makes it easier to see the problem if something goes wrong.

See Settings Files for details about the settings file itself.

Multiple settings can be defined in a build script. Every task can reference its own settings.

All Ivy variables set during the settings are available in the Ant project as long as they were not set in Ant before (Ant properties are immutable).
Moreover, the variables are exposed under two names: the variable name, and the variable name suffixed by dot + the settings id.
For instance, if you load a settings with the id 'myid', and define a variable my.variable=my.value in the Ivy settings, both my.variable and my.variable.myid will now be available as properties in Ant and equal to 'my.value'. If you later load another settings with the id 'yourid', and in this settings assign the variable 'my.variable' the value 'your.value', in the Ant project you will have:


idThe settings id useable in the settingsRef attributes of the ivy task that needs a setting. Note that the ivy tasks will search by default for the settings with the id "ivy.instance", which is the default value.No, defaults to "ivy.instance"
filepath to the settings file to use No. If a file is provided, url is ignored. If none are provided, then it attempts to find a file at ${ivy.settings.file}, and if this file does not exist, it uses a default settings file
urlurl of the settings file to use
hosthttp authentication hostNo, unless authentication is required
realmhttp authentication realm
usernamehttp authentication user name
passwdhttp authentication password

HTTP Authentication

Note: HTTP Authentication can be used only if commons-httpclient.jar is in your classpath
If any of the url you use in ivy (especially in dependency resolvers) need http
authentication, then you have to provide the host, realm, username and passwd
attributes of the configure task. These settings will then be used in any
further call to ivy tasks.

Multiple classloader

A special attention should be applied when you have a multi-project build with subant call, using ivy task loaded by a typedef. Indeed in this situation, it is possible to pass settings reference to a subbuild. When you do that, you should take of the classloader. The ivy task of your subant should not be defined in a different classloader than the parent one. This can be achieved by using the loader parameter of the antlib declaration, or avoid to reload the ivy antlib in the subbuild (place the taskdef in a target only executed when the antlib is not yet loaded).


Simplest settings

<ivy:settings />
Use either ${ivy.settings.file} if it exists, or the default settings file
This simplest setting is implicit.

Configure with a file

<ivy:settings file="mysettings.xml" />

Configure with an url

<ivy:settings url="" />

Configure multiple realms which require autentication

<ivy:settings file="path/to/my/ivysettings.xml">
<credentials host="" realm="My Realm" username="myuser" passwd="mypasswd" />
<credentials host="" realm="Your Realm" username="myuser" passwd="myotherpasswd" />

Configure 2 different settings

You can use multiple ivy settings during a build. Then every ivy task should specify the settings it uses using the settingsRef attribute.
 <ivy:settings id="ivy.normal.settings" file="normal_settings.xml" />
<ivy:settings id="ivy.release.settings" file="release_settings.xml" />

<ivy:resolve settingsRef="ivy.normal.settings" />
<ivy:resolve settingsRef="ivy.release.settings" />