587
|
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 |
package com.nokia.helium.logger.ant.types;
|
|
18 |
|
|
19 |
import java.io.File;
|
628
|
20 |
|
|
21 |
import org.apache.log4j.Logger;
|
588
|
22 |
import org.apache.tools.ant.Project;
|
587
|
23 |
import org.apache.tools.ant.types.DataType;
|
|
24 |
|
|
25 |
import com.nokia.helium.logger.ant.listener.StageSummaryHandler;
|
|
26 |
import com.nokia.helium.logger.ant.listener.StatusAndLogListener;
|
|
27 |
|
|
28 |
/**
|
|
29 |
* <code>StageSummary</code> is a Data type when set a build summary is
|
|
30 |
* displayed at the end of build process.
|
|
31 |
*
|
|
32 |
* <pre>
|
|
33 |
* Usage:
|
|
34 |
* <hlm:stagesummary id="stage.summary"
|
|
35 |
* template="${template.dir}\build_stages_summary.txt.ftl"/>
|
|
36 |
* </pre>
|
|
37 |
*
|
|
38 |
* @ant.task name="stagesummary" category="Logging"
|
|
39 |
*
|
|
40 |
*/
|
|
41 |
public class StageSummary extends DataType {
|
|
42 |
|
|
43 |
private static boolean isStageSummaryHandlerRegistered;
|
|
44 |
private File template;
|
|
45 |
private Logger log = Logger.getLogger(getClass());
|
|
46 |
|
588
|
47 |
public void setProject(Project project)
|
|
48 |
{
|
|
49 |
super.setProject(project);
|
587
|
50 |
if ( !isStageSummaryHandlerRegistered && StatusAndLogListener.getStatusAndLogListener() != null) {
|
|
51 |
log.debug("Registering stage summary to the StatusAndLogListener listener");
|
|
52 |
StatusAndLogListener.getStatusAndLogListener().register( new StageSummaryHandler() );
|
|
53 |
isStageSummaryHandlerRegistered = true;
|
|
54 |
}
|
|
55 |
}
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Get the template used for displaying build stage summary.
|
|
59 |
*
|
|
60 |
* @return the template to display build stage summary.
|
|
61 |
*/
|
588
|
62 |
public File getTemplate() {
|
587
|
63 |
return template;
|
|
64 |
}
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Set the template to be used for displaying build stage summary.
|
|
68 |
*
|
|
69 |
* @param template
|
|
70 |
* the template to set
|
|
71 |
* @ant.required
|
|
72 |
*/
|
588
|
73 |
public void setTemplate( File template ) {
|
587
|
74 |
this.template = template;
|
|
75 |
}
|
|
76 |
}
|