|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the LGPL. For more information please see |
|
17
|
|
|
* <http://phing.info>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Encapsulates a build specific event. |
|
22
|
|
|
* |
|
23
|
|
|
* <p>We have three sources of events all handled by this class: |
|
24
|
|
|
* |
|
25
|
|
|
* <ul> |
|
26
|
|
|
* <li>Project level events</li> |
|
27
|
|
|
* <li>Target level events</li> |
|
28
|
|
|
* <li>Task level events</li> |
|
29
|
|
|
* </ul> |
|
30
|
|
|
* |
|
31
|
|
|
* <p> Events are all fired from the project class by creating an event object |
|
32
|
|
|
* using this class and passing it to the listeners. |
|
33
|
|
|
* |
|
34
|
|
|
* @author Andreas Aderhold <[email protected]> |
|
35
|
|
|
* @author Hans Lellelid <[email protected]> |
|
36
|
|
|
* @package phing |
|
37
|
|
|
*/ |
|
38
|
|
|
class BuildEvent extends EventObject |
|
39
|
|
|
{ |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* A reference to the project |
|
43
|
|
|
* |
|
44
|
|
|
* @var Project |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $project; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* A reference to the target |
|
50
|
|
|
* |
|
51
|
|
|
* @var Target |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $target; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* A reference to the task |
|
57
|
|
|
* |
|
58
|
|
|
* @var Task |
|
59
|
|
|
*/ |
|
60
|
|
|
protected $task; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* The message of this event, if the event is a message |
|
64
|
|
|
* |
|
65
|
|
|
* @var string |
|
66
|
|
|
*/ |
|
67
|
|
|
protected $message = null; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* The priority of the message |
|
71
|
|
|
* |
|
72
|
|
|
* @var int |
|
73
|
|
|
* @see $message |
|
74
|
|
|
*/ |
|
75
|
|
|
protected $priority = Project::MSG_VERBOSE; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* The exception that caused the event, if any |
|
79
|
|
|
* |
|
80
|
|
|
* @var Exception |
|
81
|
|
|
*/ |
|
82
|
|
|
protected $exception = null; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Construct a BuildEvent for a project, task or target source event |
|
86
|
|
|
* |
|
87
|
|
|
* @param Project|Target|Task $source |
|
88
|
|
|
* |
|
89
|
|
|
* @throws Exception |
|
90
|
|
|
*/ |
|
91
|
783 |
|
public function __construct($source) |
|
92
|
|
|
{ |
|
93
|
783 |
|
parent::__construct($source); |
|
94
|
783 |
|
if ($source instanceof Project) { |
|
95
|
782 |
|
$this->project = $source; |
|
96
|
782 |
|
$this->target = null; |
|
97
|
782 |
|
$this->task = null; |
|
98
|
623 |
|
} elseif ($source instanceof Target) { |
|
99
|
573 |
|
$this->project = $source->getProject(); |
|
100
|
573 |
|
$this->target = $source; |
|
101
|
573 |
|
$this->task = null; |
|
102
|
623 |
|
} elseif ($source instanceof Task) { |
|
|
|
|
|
|
103
|
623 |
|
$this->project = $source->getProject(); |
|
104
|
623 |
|
$this->target = $source->getOwningTarget(); |
|
105
|
623 |
|
$this->task = $source; |
|
106
|
|
|
} else { |
|
107
|
|
|
throw new Exception("Can not construct BuildEvent, unknown source given."); |
|
108
|
|
|
} |
|
109
|
783 |
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Sets the message with details and the message priority for this event. |
|
113
|
|
|
* |
|
114
|
|
|
* @param string The string message of the event |
|
115
|
|
|
* @param integer The priority this message should have |
|
116
|
|
|
*/ |
|
117
|
782 |
|
public function setMessage($message, $priority) |
|
118
|
|
|
{ |
|
119
|
782 |
|
$this->message = (string) $message; |
|
120
|
782 |
|
$this->priority = (int) $priority; |
|
121
|
782 |
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Set the exception that was the cause of this event. |
|
125
|
|
|
* |
|
126
|
|
|
* @param Exception The exception that caused the event |
|
127
|
|
|
*/ |
|
128
|
622 |
|
public function setException($exception) |
|
129
|
|
|
{ |
|
130
|
622 |
|
$this->exception = $exception; |
|
131
|
622 |
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Returns the project instance that fired this event. |
|
135
|
|
|
* |
|
136
|
|
|
* The reference to the project instance is set by the constructor if this |
|
137
|
|
|
* event was fired from the project class. |
|
138
|
|
|
* |
|
139
|
|
|
* @return Project The project instance that fired this event |
|
140
|
|
|
*/ |
|
141
|
|
|
public function getProject() |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->project; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* Returns the target instance that fired this event. |
|
148
|
|
|
* |
|
149
|
|
|
* The reference to the target instance is set by the constructor if this |
|
150
|
|
|
* event was fired from the target class. |
|
151
|
|
|
* |
|
152
|
|
|
* @return Target The target that fired this event |
|
153
|
|
|
*/ |
|
154
|
1 |
|
public function getTarget() |
|
155
|
|
|
{ |
|
156
|
1 |
|
return $this->target; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Returns the target instance that fired this event. |
|
161
|
|
|
* |
|
162
|
|
|
* The reference to the task instance is set by the constructor if this |
|
163
|
|
|
* event was fired within a task. |
|
164
|
|
|
* |
|
165
|
|
|
* @return Task The task that fired this event |
|
166
|
|
|
*/ |
|
167
|
1 |
|
public function getTask() |
|
168
|
|
|
{ |
|
169
|
1 |
|
return $this->task; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Returns the logging message. This field will only be set for |
|
174
|
|
|
* "messageLogged" events. |
|
175
|
|
|
* |
|
176
|
|
|
* @return string The log message |
|
177
|
|
|
*/ |
|
178
|
761 |
|
public function getMessage() |
|
179
|
|
|
{ |
|
180
|
761 |
|
return $this->message; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* Returns the priority of the logging message. This field will only |
|
185
|
|
|
* be set for "messageLogged" events. |
|
186
|
|
|
* |
|
187
|
|
|
* @return integer The message priority |
|
188
|
|
|
*/ |
|
189
|
761 |
|
public function getPriority() |
|
190
|
|
|
{ |
|
191
|
761 |
|
return $this->priority; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* Returns the exception that was thrown, if any. |
|
196
|
|
|
* This field will only be set for "taskFinished", "targetFinished", and |
|
197
|
|
|
* "buildFinished" events. |
|
198
|
|
|
* |
|
199
|
|
|
* @see BuildListener::taskFinished() |
|
200
|
|
|
* @see BuildListener::targetFinished() |
|
201
|
|
|
* @see BuildListener::buildFinished() |
|
202
|
|
|
* @return Exception |
|
203
|
|
|
*/ |
|
204
|
1 |
|
public function getException() |
|
205
|
|
|
{ |
|
206
|
1 |
|
return $this->exception; |
|
207
|
|
|
} |
|
208
|
|
|
} |
|
209
|
|
|
|