triggers
Tag: triggers
since 1.4
Defines a list of triggers to activate on some Ivy events.
A trigger is an action which is performed whenever a particular event occurs.
Ivy supports two type of triggers out of the box: ant-call and ant-build. The first calls a target in the same build as the original one whenever a particular event occurs, the second call an ant build which may be in another ant build script.
If you want to use a different trigger, you can implement your own.
The event available in Ivy are the following ones:
Name | Attributes | Description |
---|---|---|
pre-resolve |
the organisation of the module for which the dependencies will be resolved the name of the module for which the dependencies will be resolved the revision of the module for which the dependencies will be resolved comma separated list of configurations which will be resolved |
Fired before a module dependencies will be resolved |
pre-resolve-dependency |
the organisation of the dependency resolved the name of the dependency resolved the revision asked for the dependency the name of the resolver used to resolve the dependency |
Fired before each dependency is resolved in a single resolve call |
post-resolve-dependency |
the organisation of the dependency resolved the name of the dependency resolved the revision of the dependency resolved, or the revision asked if the resolution was not successful true if the resolution was successful, false otherwise the name of the resolver used to resolve the dependency |
Fired after each dependency resolved in a single resolve call |
post-resolve |
the organisation of the module for which the dependencies have been resolved the name of the module for which the dependencies have been resolved the revision of the module for which the dependencies have been resolved comma separated list of configurations resolved |
Fired after a module dependencies has been resolved |
pre-download-artifact |
the organisation of the artifact which is about to be downloaded the name of the module of the artifact which is about to be downloaded the revision of the the artifact which is about to be downloaded the name of the the artifact which is about to be downloaded the type of the the artifact which is about to be downloaded the extension of the the artifact which is about to be downloaded the name of the resolver used to download the artifact the origin location from which it will be downloaded true if it's a local artifact, false otherwise |
Fired before an artifact is downloaded from a repository to the cache |
post-download-artifact |
the organisation of the artifact which was just downloaded the name of the module of the artifact which was just downloaded the revision of the the artifact which was just downloaded the name of the the artifact which was just downloaded the type of the the artifact which was just downloaded the extension of the the artifact which was just downloaded the name of the resolver used to download the artifact the origin location from which it was downloaded true if it's a local artifact, false otherwise the size in bytes of the downloaded artifact the file to which it has been downloaded |
Fired after an artifact has been downloaded from a repository to the cache |
The child tag used for the dependency resolver must be equal to a name of a trigger type (either built-in or added with the typedef tag).
Child elements
Element | Description | Cardinality |
---|---|---|
any trigger | adds a trigger to the list of registered triggers | 1..n |
Built-in Triggers
Ivy comes with two built-in triggers:
Name | Description |
---|---|
ant-build | Triggers an ant build. |
ant-call | Calls a target in the current ant build. |
Common attributes
All triggers share some common attributes detailed here.
Among these attributes, you will find how to select when the trigger should be performed. You have to provide an event name, which is simple, but you can also use a filter expression. The syntax for this expression is very simple and limited:
you can use the = operator to compare an attribute (left operande) with a value (right operande).
you can use AND OR NOT as boolean operators
you cannot use parenthesis to change the precedence
Attribute | Description | Required |
---|---|---|
name | the name of the trigger for identification purpose only | Yes |
event | the name of the event on which the trigger should be performed | Yes |
filter | a filter expression used to restrict when the trigger should be performed | No, defaults to no filter |
Examples
<triggers>
<ant-build antfile="${ivy.conf.dir}/[module]/build.xml" target="publish"
event="pre-resolve-dependency" filter="revision=latest.integration"/>
</triggers>
Triggers an ant build of the ant file ${ivy.conf.dir}/[module]/build.xml (where [module] is replaced by the name of the dependency resolved) with the target "publish", just before resolving a dependency with a latest.integration revision.
<triggers>
<ant-call target="unzip" prefix="dep"
event="post-download-artifact" filter="type=zip AND status=successful"/>
</triggers>
Triggers an ant call of the target unzip just after downloading a zip artifact, prefixing all parameters to the target with 'dep'.
Here is how the target can look like:
<target name="unzip">
<echo>
unzipping artifact:
organisation=${dep.organisation}
module=${dep.module}
revision=${dep.revision}
artifact=${dep.artifact}
type=${dep.type}
ext=${dep.ext}
origin=${dep.origin}
local=${dep.local}
size=${dep.size}
file=${dep.file}
</echo>
<mkdir dir="${basedir}/out"/>
<unzip src="${dep.file}" dest="${basedir}/out"/>
</target>