mirror of https://github.com/apache/ant-ivy
152 lines
5.8 KiB
HTML
152 lines
5.8 KiB
HTML
<!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>
|
|
<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> macrodef
|
|
|
|
<span class="tagdoc" id="ivysettings.macrodef">Defines a new dependency resolver type based upon another.</span> This definition is very similar to the macrodef feature of ant for defining macro tasks. <span class="since">since 1.3</span>
|
|
|
|
This task eases the process of creating a new dependency resolver, because it avoids writing java code.
|
|
|
|
It is generally used in combination with the [[settings/include]] feature to help reuse a macro in multiple settings files.
|
|
|
|
A macro is defined by declaring an existing resolver within it. Then you can use attributes to pass parameters to the newly defined resolver type. Attributes are defined with a name, and optionally a default value, and are used using the following syntax:
|
|
<code>@{attributename}</code>
|
|
<h2>Resolvers names</h2>
|
|
Since you can use the same macro several times it can define several resolvers (in a chain for instance), the resolver names need to be chosen carefully to avoid name conflicts (each resolver must have a unique name).
|
|
|
|
Here is how Ivy deals with the names of the resolvers defined in a macro:
|
|
<ul>
|
|
<li>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</li>
|
|
<li>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</li>
|
|
<li>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.</li>
|
|
</ul>
|
|
|
|
Example:
|
|
<code type="xml">
|
|
<ivysettings>
|
|
<macrodef name="mymacro">
|
|
<chain>
|
|
<ibiblio name="ex1" />
|
|
<ibiblio name="ex2.@{name}" m2compatible="true" />
|
|
</chain>
|
|
</macrodef>
|
|
|
|
<resolvers>
|
|
<mymacro name="default" />
|
|
<mymacro name="other" />
|
|
</resolvers>
|
|
</ivysettings>
|
|
</code>
|
|
This is equivalent to:
|
|
<code type="xml">
|
|
<ivysettings>
|
|
<resolvers>
|
|
<chain name="default">
|
|
<ibiblio name="default-ex1" />
|
|
<ibiblio name="ex2.default" m2compatible="true" />
|
|
</chain>
|
|
<chain name="other">
|
|
<ibiblio name="other-ex1" />
|
|
<ibiblio name="ex2.other" m2compatible="true" />
|
|
</chain>
|
|
</resolvers>
|
|
</ivysettings>
|
|
</code>
|
|
|
|
<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>name</td><td>name of the resover type created</td>
|
|
<td>Yes</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>[[settings/macrodef/attribute]]</td><td>defines an attribute for the macro resolver</td>
|
|
<td>0..n</td></tr>
|
|
<tr><td>any resolver</td><td>defines the base resolver upon which this macro is defined</td>
|
|
<td>1</td></tr>
|
|
</tbody>
|
|
</table>
|
|
<h1>Examples</h1>
|
|
Defining a simple macro:
|
|
<code type="xml">
|
|
<macrodef name="mymacro">
|
|
<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>
|
|
</code>
|
|
Using it:
|
|
<code type="xml">
|
|
<resolvers>
|
|
<mymacro name="default" mymainrep="path/to/myrep"/>
|
|
</resolvers>
|
|
</code>
|
|
<hr/>
|
|
A complete example:
|
|
<code type="xml">
|
|
<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>
|
|
</code>
|
|
|
|
</textarea>
|
|
<script type="text/javascript">xooki.postProcess();</script>
|
|
</body>
|
|
</html>
|