blob: f223d0773378b6cb9cec7f4b209614b8f5552697 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<script type="text/javascript">var xookiConfig = {level: 1};</script>
<script type="text/javascript" src="../xooki/xooki.js"></script>
</head>
<body>
<textarea id="xooki-source">
<b>Tag:</b> dependency <b>Parent:</b> <a href="dependencies.html">dependencies</a>
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.
<h2><a name="revision">Fixed and dynamic revisions</a></h2>
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:
<ul>
<li>latest.integration</li> selects the latest revision of the dependency module.
<li>latest.[any status] <span class="since">since 1.4</span></li> selects the latest revision of the dependency module with at least the specified status.
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.
<li>end the revision with a +</li> 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.
<li>version ranges <span class="since">since 1.4</span></li> mathematical notation for ranges can be used to match a range of version.
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
</ul>
<span class="since">since 1.4</span> If you don't find a way to expression your dependency version constraint among these, you can [[settings/version-matchers plug your own]].
The way to determine which revision is the "latest" between two is configurable through the use of pluggable LatestStrategy. See <a href="../reference.html">ivy main concepts</a> for details about this.
<h2><a name="revision-constraint">Revision constraint</a></h2>
<span class="since">since 2.0</span> 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 [[ant:resolve resolve mode]] used, the actual revision used during dependency resolution may vary. These revisions usually differ only for modules published in a repository. When [[ant: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.
<h2>Configurations mapping</h2>
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.
<ul>
<li>Specify one configuration name</li> 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 [[ivyfile/configurations configurations]] for details, or table below for examples).
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 <a href="../ivyfile/configurations.html#defaultconfmapping">examples on the dependency on the configurations page</a> explain how ivy interprets the conf attribute according to how [[ivyfile/configurations defaultconfmapping]] and [[ivyfile/configurations defaultconf]] is set.
<br/>
<li>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).</li>
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'.
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.
<span class="since">since 1.4</span> 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.
<span class="since">since 1.2</span> '@' 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.
<span class="since">since 1.4</span> '#' 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.
Example:
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 :-)
<span class="since">since 1.4</span> '%' 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.
Example:
<code>test->runtime;%->default</code> means that the <code>test</code> configuration is mapped to the <code>runtime</code> configuration, but all the other configurations are mapped to the <code>default</code> configuration.
<span class="since">since 1.3</span> 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.
For instance, <code>test->runtime(default)</code> means that in the test configuration of the module the <code>runtime</code> conf of the dependency is required, but if doesn't exist, it will use the <code>default</code> conf instead. If <code>default</code> conf doesn't exist then it will be considered as an error. Note that the <code>*</code> wildcard can be used as fallback conf.
<span class="since">since 2.1</span> It is also possible to define dependencies on configurations intersection. A configuration intersection is defined using a '+' sign to separate the configuration (eg 'A+B' means the intersection of configuration 'A' and 'B'). In that case only artifacts and dependencies defined in both configurations in the dependency will be part of the master configuration defining the dependency on the configuration intersection.
Configuration intersections can also be used when specifying the confs to [[ant:resolve]].
Moreover, the mapping '*->@' is handled as a specific case with configuration intersections: it maps also the intersections. So if one resolve conf A+B in a module which defines a dependency with mapping *->@, the mapping *->@ is interpreted as A+B->A+B so the intersection of A and B will be resolved in the dependency.
<span class="since">since 2.1</span> you can refer to a group of configurations sharing the same value for an attribute as left side part of the dependency mapping.
The syntax is
<code>*[att=value]</code>
where <em>att</em> is the name of the attribute shared by the configurations of the group, and <em>value</em is the value for this attribute that configurations must have to be part of the group. This is especially useful with extra attributes.
For instance, if you have:
<code>
<configurations>
<conf name="red" e:axis="color" />
<conf name="blue" e:axis="color" />
<conf name="windows" e:axis="platform" />
<conf name="linux" e:axis="platform"/>
</configurations>
</code>
Then you can do:
<code>
<dependency org="acme" name="foo" rev="2.0" conf="*[axis=platform]->default"/>
</code>
To map the windows and linux configurations (the one which have the attribute axis equal to platform) to the default configuration of foo.
<span class="since">since 1.4</span> you can add simple conditions in the right side of the dependency mapping. This is done by adding a condition between '[' and ']'. If the condition evaluates to <code>true</code>, the mapping is performed. If the condition evaluates to <code>false</code>, the mapping will be ignored. For instance, <code>test->[org=A]runtime,[org=B]default</code> means that the <code>test</code> configuration will be mapped to the <code>runtime</code> conf for the dependencies of organisation 'A' and to the <code>default</code> conf for dependencies of organisation 'B'.
<li>Specify a semi-column separated list of any of the previous specs.</li> In this case, it is the union of the mapping which is kept. For instance, 'A -> B; * -> C' means that B conf is needed in A conf and C conf is need in all master conf... so both B & C dep conf are required in A master conf
</ul>
If you prefer more verbose mapping declaration, everything is also possible with sub elements mapping declaration.
<h2>Artifact restriction</h2>
Moreover, the dependency element also supports an artifact restriction feature (since 0.6).
See <a href="../ivyfile/dependency-artifact.html">dependency artifact</a> for details.
<h2>Forcing revision</h2>
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 <a href="../ivyfile/conflicts.html">conflicts manager</a> for details.
<span class="since">since 1.4</span> this tag supports <a href="../concept.html#extra">extra attributes</a>
<h1>Attributes</h1>
<table class="ivy-attributes">
<thead>
<tr><th class="ivy-att">Attribute</th><th class="ivy-att-desc">Description</th><th class="ivy-att-req">Required</th></tr>
</thead>
<tbody>
<tr><td>org</td><td>the name of the organisation of the dependency.</td>
<td>No, defaults to the master module organisation</td></tr>
<tr><td>name</td><td>the module name of the dependency</td>
<td>Yes</td></tr>
<tr><td>branch</td><td>the branch of the dependency. <span class="since">since 1.4</span></td>
<td>No, defaults to the default branch [[settings/conf.html setting]] for the dependency.</td></tr>
<tr><td>rev</td><td>the revision of the dependency. See <a href="#revision">above</a> for details.</td>
<td>Yes</td></tr>
<tr><td>revConstraint</td><td>the dynamic revision constraint originally used for this dependency. See <a href="#revision-constraint">above</a> for details.</td>
<td>No, defaults to the value of rev</td></tr>
<tr><td>force</td><td>a boolean to give an indication to conflict manager that this dependency
should be forced to this revision (see <a href="../ivyfile/conflicts.html">conflicts manager</a>)</td>
<td>No, defaults to false</td></tr>
<tr><td>conf</td><td>an inline mapping configuration spec (see above for details)</td>
<td>No, defaults to defaultconf attribute of dependencies element if neither conf attribute nor conf children element is given</td></tr>
<tr><td>transitive</td><td>true to resolve this dependency transitively, false otherwise (<span class="since">since 1.2</span>)</td>
<td>No, defaults to true</td></tr>
<tr><td>changing</td><td>true if the dependency artifacts may change without revision change, false otherwise (<span class="since">since 1.2</span>). See <a href="../concept.html#change">cache and change management</a> for details.</td>
<td>No, defaults to false</td></tr>
</tbody>
</table>
<h1>Child elements</h1>
<table class="ivy-children">
<thead>
<tr><th class="ivy-chld">Element</th><th class="ivy-chld-desc">Description</th><th class="ivy-chld-card">Cardinality</th></tr>
</thead>
<tbody>
<tr><td><a href="../ivyfile/dependency-conf.html">conf</a></td><td>defines configuration mapping has sub element</td>
<td>0..n</td></tr>
<tr><td><a href="../ivyfile/dependency-artifact.html">artifact / include</a></td><td>defines artifacts inclusion - use only if you do not control dependency ivy file</td>
<td>0..n</td></tr>
<tr><td><a href="../ivyfile/artifact-exclude.html">exclude</a></td><td>defines artifacts exclusion - use only if you do not control dependency ivy file</td>
<td>0..n</td></tr>
</tbody>
</table>
<h1>Examples</h1>
<code type="xml">
<dependency org="jayasoft" name="swtbinding" revision="0.2"/>
</code>
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.
<hr/>
<code type="xml">
<dependency org="jayasoft" name="swtbinding" branch="fix-103" revision="latest.integration"/>
</code>
Same as above except that it will take the latest revision on the branch 'fix-103' instead of revision '0.2'.
<hr/>
<code type="xml">
<dependency name="mymodule" revision="latest.integration" conf="test->default"/>
</code>
Declares a dependency on the module <code>mymodule</code> 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.
<hr/>
<code type="xml">
<dependency org="apache" name="commons-lang" revision="2.0" force="true" conf="default"/>
</code>
Declares a dependency on the module <code>commons-lang</code> 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 <code>default</code> conf of commons-lang will be used in the <code>default</code> conf of the master module. If <code>*->runtime</code> 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.
<hr/>
<code type="xml">
<dependency org="foo" name="bar" revision="3.0" transitive="false" conf="default->@;runtime,test->runtime"/>
</code>
Declares a dependency on the module <code>bar</code> 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.
<hr/>
<code type="xml">
<dependency org="foo" name="bar" revision="3.0" changing="true" conf="compile->runtime(default)"/>
</code>
Declares a dependency on the module <code>bar</code> from foo, in revision 3.0. This revision is considered to be able to change (<code>changing="true"</code>), 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 <code>default</code> conf will be used.
</textarea>
<script type="text/javascript">xooki.postProcess();</script>
</body>
</html>