587
|
1 |
==========================================
|
|
2 |
Configuring Signaling: Create a new signal
|
|
3 |
==========================================
|
|
4 |
|
|
5 |
This document will help you implementing a new signal in your configuration.
|
|
6 |
|
|
7 |
Use case
|
|
8 |
--------
|
|
9 |
You have one target named **custom-action** which
|
|
10 |
should generate an artifact in some know location, and you would like the build to continue as far
|
|
11 |
as possible even if that artifact is missing, but being informed during the build it is not going as expected.
|
|
12 |
|
|
13 |
|
|
14 |
Base configuration
|
|
15 |
------------------
|
|
16 |
|
|
17 |
The following code snippet will be the base configuration for this exercise.
|
|
18 |
|
|
19 |
build.xml
|
|
20 |
|
|
21 |
.. code-block:: xml
|
|
22 |
|
|
23 |
<?xml version="1.0" ?>
|
|
24 |
<project name="config" default="test" xmlns:hlm="http://www.nokia.com/helium">
|
|
25 |
<property environment="env"/>
|
|
26 |
<import file="${helium.dir}/helium_preinclude.ant.xml"/>
|
|
27 |
|
|
28 |
<!-- Location of the artifact -->
|
|
29 |
<property name="artifact" location="artifact.txt"/>
|
|
30 |
|
|
31 |
<import file="${helium.dir}/helium.ant.xml"/>
|
|
32 |
|
|
33 |
<!-- The target -->
|
|
34 |
<target name="custom-action">
|
|
35 |
<delete failonerror="false" file="${artifact}"/>
|
|
36 |
<if>
|
|
37 |
<istrue value="${create.artifact}"/>
|
|
38 |
<then>
|
|
39 |
<echo file="${artifact}">My artifact</echo>
|
|
40 |
</then>
|
|
41 |
</if>
|
|
42 |
</target>
|
|
43 |
|
|
44 |
<target name="custom-dummy">
|
|
45 |
<echo message="Dummy action"/>
|
|
46 |
</target>
|
|
47 |
|
|
48 |
</project>
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
To declare a new signal to the framework you need to define a new signalListenerConfig reference.
|
|
53 |
You also need to create a signalInput configuration to define your signal behaviour.
|
|
54 |
|
|
55 |
.. code-block:: xml
|
|
56 |
|
|
57 |
<hlm:signalInput id="customActionSignalInput" failbuild="defer"/>
|
|
58 |
|
|
59 |
<hlm:signalListenerConfig id="customActionSignal" target="custom-action" message="custom-action target ended.">
|
|
60 |
<signalNotifierInput>
|
|
61 |
<signalInput refid="customActionSignalInput" />
|
|
62 |
<notifierInput file="${artifact}" />
|
|
63 |
</signalNotifierInput>
|
|
64 |
<hlm:targetCondition>
|
|
65 |
<not><available file="${artifact}"/></not>
|
|
66 |
</hlm:targetCondition>
|
|
67 |
</hlm:signalListenerConfig>
|
|
68 |
|
|
69 |
|
|
70 |
The signalListenerConfig defines which target to listen and raise signal for. The target name is defined through the **target** attribute.
|
|
71 |
Then the nested **targetCondition** element is used to configure how the signal should be triggered.
|
|
72 |
This element accepts any nested `Ant conditions <http://ant.apache.org/manual/CoreTasks/conditions.html>`_.
|
|
73 |
In this case the signal will get raised only if the file is not present after the execution of the **custom-action** target.
|
|
74 |
|
|
75 |
The framework then uses the defined signalInput from the signalNotifierInput configuration to know how to behave when the signal is raised. In the previous example it will
|
|
76 |
simply keep running and fail the build at the end. Then files defined by the nested notifierInput will be passed to the notifier.
|
|
77 |
|
|
78 |
The execution of the **custom-action custom-dummy** build sequence will happen entirely even if the artifact is not
|
|
79 |
created properly, then fail the build mentioning the faulty target::
|
|
80 |
|
|
81 |
> hlm custom-action custom-dummy
|
|
82 |
Internal data listening enabled.
|
|
83 |
Buildfile: build.xml
|
|
84 |
[echo] Using build drive X:
|
|
85 |
|
|
86 |
custom-action:
|
|
87 |
18:21:14,503 INFO - Signal customActionSignal will be deferred.
|
|
88 |
|
|
89 |
custom-dummy:
|
|
90 |
[echo] Dummy action
|
|
91 |
|
|
92 |
BUILD FAILED
|
|
93 |
customActionSignal: custom-action target ended. : custom-action
|
|
94 |
|
|
95 |
|
|
96 |
Total time: 2 seconds
|
|
97 |
|
|
98 |
|
|
99 |
If you enable the artifact creation then the build will proceed successfully::
|
|
100 |
|
|
101 |
>hlm custom-action custom-dummy -Dcreate.artifact=true
|
|
102 |
Internal data listening enabled.
|
|
103 |
Buildfile: build.xml
|
|
104 |
[echo] Using build drive X:
|
|
105 |
|
|
106 |
custom-action:
|
|
107 |
|
|
108 |
custom-dummy:
|
|
109 |
[echo] Dummy action
|
|
110 |
|
|
111 |
BUILD SUCCESSFUL
|
|
112 |
Total time: 2 seconds
|
|
113 |
|
|
114 |
|