- Home
- Download
- Documentation (2.0.0-beta1)
- History
- Trunk
- 2.x
- 2.0.x
- 2.0.0-beta1
- 2.0.0-alpha2
- 2.0.0-alpha-1
- 2.0.x
- 1.x
- 0.x
- Get Involved
- Search
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 |
|
Fired before a module dependencies will be resolved |
pre-resolve-dependency |
|
Fired before each dependency is resolved in a single resolve call |
post-resolve-dependency |
|
Fired after each dependency resolved in a single resolve call |
post-resolve |
|
Fired after a module dependencies has been resolved |
pre-download-artifact |
|
Fired before an artifact is downloaded from a repository to the cache |
post-download-artifact |
|
Fired after an artifact has been downloaded from a repository to the cache |
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>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.
<ant-build antfile="${ivy.settings.dir}/[module]/build.xml" target="publish"
event="pre-resolve-dependency" filter="revision=latest.integration"/>
</triggers>
<triggers>Triggers an ant call of the target unzip just after downloading a zip artifact, prefixing all parameters to the target with 'dep'.
<ant-call target="unzip" prefix="dep"
event="post-download-artifact" filter="type=zip AND status=successful"/>
</triggers>
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>