- Documentation (2.5.1-local-20221102182706)
- Release Notes
- Tutorials
- Reference
- Introduction
- Settings Files
- Ivy Files
- Ant Tasks
- artifactproperty
- artifactreport
- buildlist
- buildnumber
- buildobr
- cachefileset
- cachepath
- checkdepsupdate
- cleancache
- configure
- convertmanifest
- convertpom
- deliver
- dependencytree
- findrevision
- fixdeps
- info
- install
- listmodules
- makepom
- post resolve tasks
- publish
- report
- repreport
- resolve
- resources
- retrieve
- settings
- var
- Using standalone
- OSGi
- Developer doc
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 3 type of triggers out of the box:
-
ant-call
calls a target in the same build as the original one whenever a particular event occurs. -
ant-build
calls an Ant build which may be in another Ant build script. -
log
echo a message, usually in a file
If you want to use a different trigger, you can implement your own.
The following events are available in Ivy:
Name | Attributes | Description |
---|---|---|
pre-resolve |
* organisation * module * revision * conf |
Fired at the beginning of the resolve process, before module dependencies and transitive dependencies are resolved. |
pre-resolve-dependency |
* organisation * module * req-revision * req-revision-default * req-revision-dynamic * revision * resolver |
Fired before each dependency is resolved. In this case resolved means resolving the actual revision if the requested revision is a version constraint and not a static version, and downloading all necessary metadata information. |
post-resolve-dependency |
* organisation * module * req-revision * req-revision-default * req-revision-dynamic * revision * resolved * duration * resolver * any extra attribute |
Fired after each dependency is resolved |
post-resolve |
* organisation * module * revision * conf * resolve-id * nb-dependencies * nb-artifacts * resolve-duration * download-duration * download-size |
Fired at the end of the resolve process, when all module dependencies have been resolved |
pre-download-artifact |
* organisation * module * revision * artifact * type * ext * metadata * resolver * origin * local |
Fired before an artifact is downloaded from a repository to the cache |
post-download-artifact |
* organisation * module * revision * artifact * type * ext * metadata * resolver * origin * local * size * duration * file |
Fired after an artifact has been downloaded from a repository to the cache |
pre-retrieve (since 2.0) |
* organisation * module * revision * conf * symlink * sync |
Fired at the beginning of the retrieve process. |
post-retrieve (since 2.0) |
* organisation * module * revision * conf * symlink * sync * duration * size * nbCopied * nbUptodate |
Fired at the end of the retrieve process. |
pre-retrieve-artifact (since 2.1) |
* organisation * module * revision * artifact * type * ext * metadata * size * from * to |
Fired before an artifact is retrieved from the cache to a local location |
post-retrieve-artifact (since 2.1) |
* organisation * module * revision * artifact * type * ext * metadata * size * from * to |
Fired after an artifact is retrieved from the cache to a local location |
pre-publish-artifact (since 2.0) |
* organisation * module * revision * artifact * type * ext * resolver * file * overwrite |
Fired before an artifact is published into a repository |
post-publish-artifact (since 2.0) |
* organisation * module * revision * artifact * type * ext * resolver * file * overwrite * status |
Fired after an artifact is published into a repository. Note that this event is fired whether or not the publication succeeded. The "status" property can be checked to verify success. |
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 3 built-in triggers:
Name | Description |
---|---|
ant-build |
Triggers an Ant build. Note that by default the Ant build is triggered only once per build file, the property onlyonce can be set to false to change this. |
ant-call |
Calls a target in the current Ant build. |
log |
Logs a message on the console or in a log file. |
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 operand) with a value (right operand).
-
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.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.
Note that by default the Ant build is triggered only once per build file. See below to see how to trigger the build more than once.
<triggers>
<ant-build antfile="${ivy.settings.dir}/[module]/build.xml" target="publish"
event="pre-resolve-dependency" filter="revision=latest.integration"
onlyonce="false"/>
</triggers>
Same as before, but this time the builds will be triggered as many time as the dependency is resolved, instead of only once.
<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>
<triggers>
<log file="ivy.log"
message='downloaded "${origin}" to "${file}" (${duration}ms - ${size}B)'
event="post-download-artifact" filter="status=successful"/>
</triggers>
Logs any successful artifact download, with information on the source and destination, and details on download size and duration.
The file
attribute is optional, the log trigger will output messages to console if it isn’t provided.