- Documentation
macrodef
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 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}.
Attributes
Attribute | Description | Required |
---|---|---|
name | name of the resover type created | Yes |
Child elements
Element | Description | Cardinality |
---|---|---|
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:<macrodef name="mymacro">Using it:
<attribute name="mymainrep"/>
<filesystem name="fs1">
<ivy pattern="@{mymainrep}/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
<artifact pattern="@{mymainrep}/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
</filesystem>
</macrodef>
<resolvers>
<mymacro name="default" mymainrep="path/to/myrep"/>
</resolvers>
A complete example:
<ivysettings>
<macrodef name="mymacro">
<attribute name="mymainrep"/>
<attribute name="mysecondrep"/>
<attribute name="myseconddirlayout" default="[organisation]/[module]/[type]s"/>
<chain>
<filesystem name="fs1">
<ivy pattern="@{mymainrep}/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
<artifact pattern="@{mymainrep}/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
</filesystem>
<filesystem name="fs2" latest="latest-time">
<ivy pattern="@{mysecondrep}/@{myseconddirlayout}/ivy-[revision].xml"/>
<artifact pattern="@{mysecondrep}/@{myseconddirlayout}/[artifact]-[revision].[ext]"/>
</filesystem>
</chain>
</macrodef>
<resolvers>
<mymacro name="default" mymainrep="path/to/myrep" mysecondrep="path/to/secondrep"/>
<mymacro name="other"
mymainrep="path/to/myrep"
mysecondrep="path/to/secondrep"
myseconddirlayout="[module]/[type]s"/>
</resolvers>
</ivysettings>