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.metadata.ant.taskdefs;
|
|
19 |
|
|
20 |
import java.io.File;
|
628
|
21 |
import java.util.ArrayList;
|
|
22 |
import java.util.List;
|
588
|
23 |
|
|
24 |
import org.apache.tools.ant.BuildException;
|
628
|
25 |
import org.apache.tools.ant.Project;
|
588
|
26 |
import org.apache.tools.ant.Task;
|
628
|
27 |
import org.apache.tools.ant.types.ResourceCollection;
|
|
28 |
|
|
29 |
import com.nokia.helium.metadata.MetadataException;
|
588
|
30 |
import com.nokia.helium.metadata.ant.conditions.MetaDataLogCondition;
|
628
|
31 |
import com.nokia.helium.metadata.ant.types.SeverityEnum;
|
588
|
32 |
|
|
33 |
/**
|
|
34 |
* This class sets a property to the number of matching severity inside a Metadata db for a log.
|
|
35 |
* Example:
|
|
36 |
* <pre>
|
628
|
37 |
* <hlm:metadataCountSeverity severity="error"
|
|
38 |
* log="${compile.log.dir}/${build.id}_fixslashes_raptor.log"
|
|
39 |
* database="${build.log.dir}/metadata_db"
|
|
40 |
* property="fixslashes.error" />
|
588
|
41 |
* </pre>
|
|
42 |
|
|
43 |
* @ant.task name="metadataCountSeverity" category="Metadata"
|
|
44 |
*/
|
|
45 |
public class MetaDataLogCountTask extends Task {
|
|
46 |
|
628
|
47 |
private File database;
|
|
48 |
private File log;
|
|
49 |
private SeverityEnum severity;
|
588
|
50 |
private String property;
|
628
|
51 |
private List<ResourceCollection> resourceCollections = new ArrayList<ResourceCollection>();
|
|
52 |
|
|
53 |
public void add(ResourceCollection resourceCollection) {
|
|
54 |
resourceCollections.add(resourceCollection);
|
|
55 |
}
|
588
|
56 |
|
|
57 |
/**
|
628
|
58 |
* Location of the database.
|
588
|
59 |
*
|
|
60 |
* @param filename
|
|
61 |
* @ant.required
|
|
62 |
*/
|
628
|
63 |
@Deprecated
|
|
64 |
public void setDb(File database) {
|
|
65 |
log("The usage of the db attribute is deprecated, please use the database attribute instead.", Project.MSG_WARN);
|
|
66 |
this.database = database;
|
|
67 |
}
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Location of the database.
|
|
71 |
*
|
|
72 |
* @param filename
|
|
73 |
* @ant.required
|
|
74 |
*/
|
|
75 |
public void setDatabase(File database) {
|
|
76 |
this.database = database;
|
588
|
77 |
}
|
|
78 |
|
628
|
79 |
public void setLog(File log) {
|
|
80 |
this.log = log;
|
588
|
81 |
}
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Defines the severity name to be counted.
|
|
85 |
*
|
|
86 |
* @param severity
|
|
87 |
* @ant.required
|
|
88 |
*/
|
628
|
89 |
public void setSeverity(SeverityEnum severity) {
|
588
|
90 |
this.severity = severity;
|
|
91 |
}
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Name of the property to be set.
|
|
95 |
* @param property the property name
|
|
96 |
* @ant.required
|
|
97 |
*/
|
|
98 |
public void setProperty(String property) {
|
|
99 |
this.property = property;
|
|
100 |
}
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Should the count of missing files for error severity.
|
|
104 |
* @param countMissing enable the count of missing files
|
|
105 |
* for error severity
|
|
106 |
* @ant.not-required Default is true
|
|
107 |
*/
|
628
|
108 |
@Deprecated
|
588
|
109 |
public void setCountMissing(boolean countMissing) {
|
628
|
110 |
// not active anymore
|
588
|
111 |
}
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Execute the task. Set the property with number of severities.
|
|
115 |
* @throws BuildException
|
|
116 |
*/
|
|
117 |
public void execute() {
|
628
|
118 |
if (property == null) {
|
588
|
119 |
throw new BuildException("'property' attribute is not defined");
|
628
|
120 |
}
|
|
121 |
try {
|
|
122 |
MetaDataLogCondition cond = new MetaDataLogCondition();
|
|
123 |
cond.setProject(getProject());
|
|
124 |
cond.setDatabase(database);
|
|
125 |
cond.setLog(log);
|
|
126 |
cond.setSeverity(severity);
|
|
127 |
for (ResourceCollection rc : resourceCollections) {
|
|
128 |
cond.add(rc);
|
|
129 |
}
|
|
130 |
getProject().setNewProperty(property, "" + cond.getSeverity());
|
|
131 |
} catch (MetadataException ex) {
|
|
132 |
throw new BuildException(ex.getMessage(), ex);
|
|
133 |
}
|
588
|
134 |
}
|
|
135 |
} |