Home


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.

Fixed and dynamic revisions

The revision can be given as a fixed one (1.5.2, for instance) or as a latest (or dynamic) one. Several possibilities for dynamic revisions are implemented in Ivy:
  • 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.
    See also settings/statuses to see how to configure module statuses.
  • end the revision with a +
  • selects the latest sub-revision of the dependency module. For instance,
    if the dependency module exists in revision 1.0.3, 1.0.7 and 1.1.2, "1.0.+" will select 1.0.7.
  • version ranges
  • mathematical notation for ranges can be used to match a range of version. since 1.4 Examples:
    [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
since 1.4 If you don't find a way to expression your dependency version constraint among these, you can plug your own.
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.

Revision constraint

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 mapping

This 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.
If you prefer more verbose mapping declaration, everything is also possible with sub elements mapping declaration.

Artifact restriction

Moreover, the dependency element also supports an artifact restriction feature (since 0.6).
See
dependency artifact restriction for details.

Forcing revision

Finally, 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

Attributes

AttributeDescriptionRequired
orgthe name of the organisation of the dependency. No, defaults to the master module organisation
namethe module name of the dependency Yes
branchthe branch of the dependency. since 1.4 No, defaults to the default branch setting for the dependency.
revthe revision of the dependency. See above for details. Yes
revConstraintthe dynamic revision constraint originally used for this dependency. See above for details. No, defaults to the value of rev
forcea boolean to give an indication to conflict manager that this dependency
should be forced to this revision (see conflicts manager)
No, defaults to false
confan 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
transitivetrue to resolve this dependency transitively, false otherwise (since 1.2) No, defaults to true
changingtrue 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

Child elements

ElementDescriptionCardinality
confdefines configuration mapping has sub element 0..n
artifact / includedefines artifacts inclusion - use only if you do not control dependency ivy file 0..n
excludedefines artifacts exclusion - use only if you do not control dependency ivy file 0..n

Examples

<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
mymodule
from 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-lang
from 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
default
conf of commons-lang will be used in the
default
conf of the master module. If
*->runtime
was 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
bar
from 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
bar
from 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
default
conf will be used.