588
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.helium.internaldata.ant.taskdefs;
|
|
19 |
|
628
|
20 |
import org.apache.tools.ant.BuildException;
|
588
|
21 |
import org.apache.tools.ant.Task;
|
628
|
22 |
|
588
|
23 |
import com.nokia.helium.internaldata.ant.listener.Listener;
|
|
24 |
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Task to identify failing assert and push them to the internal data database.
|
|
28 |
*
|
|
29 |
* Usage:
|
|
30 |
* <pre>
|
|
31 |
* <hlm:hlmassertmessage assertName="hlm:assertPropertySet" message="Warning: @{message}"/>
|
|
32 |
* </pre>
|
|
33 |
*
|
|
34 |
* @ant.task name=hlmassertmessage category=internaldata
|
|
35 |
*/
|
|
36 |
public class HlmAssertMessageTask extends Task {
|
|
37 |
|
|
38 |
private String message;
|
|
39 |
private String assertName;
|
|
40 |
|
|
41 |
/**
|
|
42 |
* {@inheritDoc}
|
|
43 |
*/
|
|
44 |
public void execute() {
|
|
45 |
|
628
|
46 |
if (assertName == null) {
|
588
|
47 |
throw new BuildException("'assertName' attribute is not defined");
|
628
|
48 |
}
|
|
49 |
if (message == null) {
|
588
|
50 |
throw new BuildException("'message' attribute is not defined");
|
628
|
51 |
}
|
588
|
52 |
|
|
53 |
for (int i = 0 ; i < getProject().getBuildListeners().size() ; i++) {
|
|
54 |
if (getProject().getBuildListeners().get(i) instanceof Listener) {
|
|
55 |
Listener listen = (Listener)getProject().getBuildListeners().get(i);
|
|
56 |
listen.addAssertTask(this);
|
|
57 |
break;
|
|
58 |
}
|
|
59 |
}
|
|
60 |
}
|
|
61 |
/**
|
|
62 |
* Returns assert name.
|
|
63 |
* @return
|
|
64 |
*/
|
|
65 |
public String getAssertName()
|
|
66 |
{
|
|
67 |
return assertName;
|
|
68 |
}
|
|
69 |
/**
|
|
70 |
* Set the assertname.
|
|
71 |
* @param assertName
|
|
72 |
*/
|
|
73 |
public void setAssertName(String assertName)
|
|
74 |
{
|
|
75 |
this.assertName = assertName;
|
|
76 |
}
|
|
77 |
/**
|
|
78 |
* Return the assert message.
|
|
79 |
* @return
|
|
80 |
*/
|
|
81 |
public String getMessage()
|
|
82 |
{
|
|
83 |
return message;
|
|
84 |
}
|
|
85 |
/**
|
|
86 |
* Set the assert message.
|
|
87 |
* @param message
|
|
88 |
*/
|
|
89 |
public void setMessage(String message)
|
|
90 |
{
|
|
91 |
this.message = message;
|
|
92 |
}
|
|
93 |
|
|
94 |
}
|