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:
NameAttributesDescription
pre-resolve
  • organisation
  • the organisation of the module for which the dependencies will be resolved
  • module
  • the name of the module for which the dependencies will be resolved
  • revision
  • the revision of the module for which the dependencies will be resolved
  • conf
  • comma separated list of configurations which will be resolved
Fired before a module dependencies will be resolved
pre-resolve-dependency
  • organisation
  • the organisation of the dependency resolved
  • module
  • the name of the dependency resolved
  • revision
  • the revision asked for the dependency
  • resolver
  • the name of the resolver used to resolve the dependency
Fired before each dependency is resolved in a single resolve call
post-resolve-dependency
  • organisation
  • the organisation of the dependency resolved
  • module
  • the name of the dependency resolved
  • revision
  • the revision of the dependency resolved, or the revision asked if the resolution was not successful
  • resolved
  • true if the resolution was successful, false otherwise
  • resolver
  • the name of the resolver used to resolve the dependency
Fired after each dependency resolved in a single resolve call
post-resolve
  • organisation
  • the organisation of the module for which the dependencies have been resolved
  • module
  • the name of the module for which the dependencies have been resolved
  • revision
  • the revision of the module for which the dependencies have been resolved
  • conf
  • comma separated list of configurations resolved
Fired after a module dependencies has been resolved
pre-download-artifact
  • organisation
  • the organisation of the artifact which is about to be downloaded
  • module
  • the name of the module of the artifact which is about to be downloaded
  • revision
  • the revision of the the artifact which is about to be downloaded
  • artifact
  • the name of the the artifact which is about to be downloaded
  • type
  • the type of the the artifact which is about to be downloaded
  • ext
  • the extension of the the artifact which is about to be downloaded
  • resolver
  • the name of the resolver used to download the artifact
  • origin
  • the origin location from which it will be downloaded
  • local
  • true if it's a local artifact, false otherwise
Fired before an artifact is downloaded from a repository to the cache
post-download-artifact
  • organisation
  • the organisation of the artifact which was just downloaded
  • module
  • the name of the module of the artifact which was just downloaded
  • revision
  • the revision of the the artifact which was just downloaded
  • artifact
  • the name of the the artifact which was just downloaded
  • type
  • the type of the the artifact which was just downloaded
  • ext
  • the extension of the the artifact which was just downloaded
  • resolver
  • the name of the resolver used to download the artifact
  • origin
  • the origin location from which it was downloaded
  • local
  • true if it's a local artifact, false otherwise
  • size
  • the size in bytes of the downloaded artifact
  • file
  • 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

ElementDescriptionCardinality
any triggeradds a trigger to the list of registered triggers 1..n

Built-in Triggers

Ivy comes with two built-in triggers:
NameDescription
ant-buildTriggers an ant build.
ant-callCalls 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
AttributeDescriptionRequired
namethe name of the trigger for identification purpose only Yes
eventthe name of the event on which the trigger should be performed Yes
filtera filter expression used to restrict when the trigger should be performed No, defaults to no filter

Examples

<triggers>
<ant-build antfile="${ivy.settings.dir}/[module]/build.xml" target="publish"
event="pre-resolve-dependency" filter="revision=latest.integration"/>
</triggers>
Triggers an ant build of the ant file ${ivy.settings.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>