- Documentation (2.0.0)
- Release Notes
- Settings Files
- Ivy Files
- Ant Tasks
- Using standalone
- Developer doc
Tag: dependency Parent: dependencies
Declares a dependency for this module. A dependency is described by the module on which the current module depends (identified by its name, organisation and revision), and a mapping of configurations.
- latest.integration selects the latest revision of the dependency module.
- latest.[any status] selects the latest revision of the dependency module with at least the specified status. since 1.4 For instance latest.milestone will select the latest version being either a milestone or a release, and latest.release will only selects the latest release. Note that in order to find the latest revision with the appropriate status Ivy has to parse all the ivy files in your repository from the last one until it finds such a revision. Hence don't be surprised if the resolution slow down.
- end the revision with a + selects the latest sub-revision of the dependency module. For instance,
- version ranges mathematical notation for ranges can be used to match a range of version. since 1.4 Examples:
See also statuses to see how to configure module statuses.
if the dependency module exists in revision 1.0.3, 1.0.7 and 1.1.2, "1.0.+" will select 1.0.7.
[1.0,2.0] matches all versions greater or equal to 1.0 and lower or equal to 2.0
[1.0,2.0[ matches all versions greater or equal to 1.0 and lower than 2.0
]1.0,2.0] matches all versions greater than 1.0 and lower or equal to 2.0
]1.0,2.0[ matches all versions greater than 1.0 and lower than 2.0
[1.0,) matches all versions greater or equal to 1.0
]1.0,) matches all versions greater than 1.0
(,2.0] matches all versions lower or equal to 2.0
(,2.0[ matches all versions lower than 2.0
The way to determine which revision is the "latest" between two is configurable through the use of pluggable LatestStrategy. See ivy main concepts for details about this.
since 2.0 The dependency tag supports two revision attributes: rev, corresponding to the default required dependency revision, and revConstraint, corresponding to a dynamic revision constraint applied on this dependency.
Depending on the resolve mode used, the actual revision used during dependency resolution may vary. These revisions usually differ only for modules published in a repository. When deliver is used, dynamic version constraints are replaced by a stic version constraint, to help build reproducibility. However, the information of the original version constraint is not lost, but rather put in the revConstraint attribute. This both ensure better metadata in the repository while still allowing easier build reproducibility.
Configurations mappingThis mapping indicates which configurations of the dependency are required in which configurations of the current module, also called master configurations.
There are several ways to declare this mapping of configurations, choose depending more on preference than on possibilities. Try to avoid mixing usage in a single dependency element: do not use both nested and inline mapping declaration.
The first way to declare this mapping is called the inline mapping. It is maybe the less natural at first, but it's powerful and concise. Inline mapping can take several forms.
- Specify one configuration name This means that in this master configuration the same dependency configuration is needed (except if a defaultconfmapping has been specified in this ivy file, see configurations for details, or table below for examples).
- Specify a configuration mapping using the '->' operator separating a comma separated list of master configurations (left operand) of a comma separated list of dependency configurations (right operand). A good way to remember which side is for the master configuration (i.e. the configuration of the module defining the dependency) and which side is for the dependency configuration is to read the '->' as 'depends on'.
For instance, if the current module has defined a configuration named 'runtime', and the dependency too, then having an inline mapping configuration set to 'runtime' means that in the runtime master configuration the runtime dependency configuration is required.
The table below indicates how ivy interpret the conf attribute according to how defaultconfmapping is set:
In this case, all specified dependency configurations are required in all specified master configurations.
For instance, 'A, B, C -> E, F' means that dependency configurations E & F are required in master configurations A, B and C.
Note that you can use the wildcard '*' as a configuration name, meaning that all configurations (either master or dependency public ones depending on the side) are wanted. For instance, '* -> B, C' means that B & C dependency configurations are required in all master configurations.
since 1.4 you can use * wildcard followed by negated configurations to mean all but xxx. For instance, '*, !A, !B -> X' means that X dependency configuration is required in all master configurations except A and B.
since 1.2 '@' also has a special meaning as a right operand of the dependency mapping, it means map to self. This is particularly useful with '*', '*->@' meaning that all configurations of the module maps to their equivalent (same name) in the dependency.
since 1.4 '#' can be used as right side operand to mean 'this' configuration, and thus refers to the configuration being resolved. It is slightly similar to @, except that it takes into account the configuration being actually resolved in case of a configuration extending another one.
Let's foo be a module with two configurations, A and B, B extending A.
Then a dependency declaring conf A-># will get A dep conf in its confs A (when resolving A, ivy will find interpret the # symbol as A) and B dep conf in its conf B (when resolving B, ivy will interpret the # symbol as B, even if this dependency is only required because of the A dependency).
If you don't understand really how this works, do not use it :-)
since 1.4 '%' can be used as left side operand to mean 'all the other configurations'. This can be usefull when you only have a specific mapping for some configurations and a default mapping for all the others.
test->runtime;%->defaultmeans that the
testconfiguration is mapped to the
runtimeconfiguration, but all the other configurations are mapped to the
since 1.3 a fallback mechanism can be used when you are not sure that the dependency will have the required conf. You can indicate to ivy that you want one configuration, but if it isn't present, use another one.
The syntax for specifying this adds the fallback conf between parenthesis right after the required conf.
test->runtime(default)means that in the test configuration of the module the
runtimeconf of the dependency is required, but if doesn't exist, it will use the
defaultconf instead. If
defaultconf doesn't exist then it will be considered as an error. Note that the
*wildcard can be used as fallback conf.
since 1.4 you can add simple conditions in the dependency mapping. This is done by adding a condition between '[' and ']'. If the condition evaluates to
true, the mapping is performed. If the condition evaluates to
false, the mapping will be ignored. For instance,
test->[org=A]runtime,[org=B]defaultmeans that the
testconfiguration will be mapped to the
runtimeconf for the dependencies of organisation 'A' and to the
defaultconf for dependencies of organisation 'B'.
Artifact restrictionMoreover, the dependency element also supports an artifact restriction feature (since 0.6).
See dependency artifact restriction for details.
Forcing revisionFinally, the dependency element also supports an a force attribute (since 0.8), which gives an indication
to conflicts manager to force the revision of a dependency to the one given here.
See conflicts manager for details.
since 1.4 this tag supports extra attributes
|org||the name of the organisation of the dependency.||No, defaults to the master module organisation|
|name||the module name of the dependency||Yes|
|branch||the branch of the dependency. since 1.4||No, defaults to the default branch setting for the dependency.|
|rev||the revision of the dependency. See above for details.||Yes|
|revConstraint||the dynamic revision constraint originally used for this dependency. See above for details.||No, defaults to the value of rev|
|force||a boolean to give an indication to conflict manager that this dependency
should be forced to this revision (see conflicts manager)
|No, defaults to false|
|conf||an inline mapping configuration spec (see above for details)||No, defaults to defaultconf attribute of dependencies element if neither conf attribute nor conf children element is given|
|transitive||true to resolve this dependency transitively, false otherwise (since 1.2)||No, defaults to true|
|changing||true if the dependency artifacts may change without revision change, false otherwise (since 1.2). See cache and change management for details.||No, defaults to false|
|conf||defines configuration mapping has sub element||0..n|
|artifact / include||defines artifacts inclusion - use only if you do not control dependency ivy file||0..n|
|exclude||defines artifacts exclusion - use only if you do not control dependency ivy file||0..n|
<dependency org="jayasoft" name="swtbinding" revision="0.2"/>Declares a dependency on the module swtbinding from jayasoft in its revision 0.2. All the configuration of this dependency will be included in all configurations of the module in which the dependency is declared.
<dependency org="jayasoft" name="swtbinding" branch="fix-103" revision="latest.integration"/>Same as above except that it will take the latest revision on the branch 'fix-103' instead of revision '0.2'.
<dependency name="mymodule" revision="latest.integration" conf="test->default"/>Declares a dependency on the module
mymodulefrom the same organisation as the module in which the dependency is declared. The latest available revision of this dependency will be used. This dependency will only be included in the test configuration of the module, and it's only the default configuration of the dependency which will be included.
<dependency org="apache" name="commons-lang" revision="2.0" force="true" conf="default"/>Declares a dependency on the module
commons-langfrom apache, in revision 2.0. The revision 2.0 will be used even if another dependency declares itself a dependency on another version of commons-lang. Moreover, if no defaultconfmapping is defined, only the
defaultconf of commons-lang will be used in the
defaultconf of the master module. If
*->runtimewas declared as defaultconfmapping, then the runtime conf of commons-lang would be included in the default conf of the master module. Note that whatever the defaultconfmapping is, the dependency only be included in the default conf of the master module. The defaultconfmapping only changes the required dependency confs.
<dependency org="foo" name="bar" revision="3.0" transitive="false" conf="default->@;runtime,test->runtime"/>Declares a dependency on the module
barfrom foo, in revision 3.0. The dependencies of bar will themselves not be included due to the setting of transitive. The default dependency conf will be included in the default master conf, and the runtime dependency conf will be included in both the runtime and test master conf.
<dependency org="foo" name="bar" revision="3.0" changing="true" conf="compile->runtime(default)"/>Declares a dependency on the module
barfrom foo, in revision 3.0. This revision is considered to be able to change (
changing="true"), so even if it is already in ivy cache, Ivy will check if a revision is a more recent last modified date is available on the repository. The runtime conf of bar is required in the compile conf of the master module, but if bar doesn't define a runtime conf, then the
defaultconf will be used.