Tag:
macrodef
Defines a new dependency resolver type based upon an other one.
This definition is very similar to the macrodef feature of ant for defining macro tasks.
since 1.3
This task eases the lot the process of creating new dependency resolver, because it avoid writing java code. It is generally used in combination with the [[settings/include]] feature to help reusing macro at several places. A macro is defined by writing the resolver it is equivalent to as if it were written in the resolver place, except that you can use attributes to pass parameters to the newly defined resolver type. Attributes are defined with a name and sometimes a default value, and are used using the following syntax:
@{attributename}
Resolvers names
Since you can use the same macro several times, and that your macro may define several resolvers (in a chain for instance), resolvers names need to be chosen carefully to avoid name conflicts (a resolver must have a unique name). Therefore here is how Ivy deals with the names of the resolvers defined in a macro:
if there is no name attribute on a resolver in the macrodef, then Ivy will use the name given when using the macro. This is what usually should be done for the main resolver defined in the macro
if there is a name attribute on a resolver in the macrodef, but this name doesn't contain a @{name} inside, then Ivy will use the provided name prefixed with the name of the macro separated by a dash
if there is a name attribute on a resolver in the macrodef, and this name contains @{name} somewhere, then Ivy will use this name, and replace @{name} with the name provided when using the macro.
Example:
This is equivalent to:
Attributes
Attribute
Description
Required
name
name of the resover type created
Yes
Child elements
Element
Description
Cardinality
[[settings/macrodef/attribute]]
defines an attribute for the macro resolver
0..n
any resolver
defines the base resolver upon which this macro is defined
1
Examples
Defining a simple macro:
Using it:
A complete example: