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.ant.data;
|
|
18 |
|
|
19 |
import java.util.ArrayList;
|
|
20 |
import java.util.List;
|
|
21 |
|
|
22 |
import org.apache.tools.ant.Project;
|
|
23 |
import org.dom4j.Element;
|
|
24 |
import org.dom4j.Node;
|
|
25 |
import org.dom4j.Visitor;
|
|
26 |
import org.dom4j.VisitorSupport;
|
|
27 |
|
|
28 |
/**
|
|
29 |
* Meta data for Ant objects that can contain other tasks.
|
|
30 |
*/
|
|
31 |
public class TaskContainerMeta extends AntObjectMeta {
|
|
32 |
private ArrayList<String> antcallTargets;
|
|
33 |
private ArrayList<String> logs;
|
|
34 |
private ArrayList<String> signals;
|
|
35 |
private ArrayList<String> executables;
|
|
36 |
|
628
|
37 |
public TaskContainerMeta(AntObjectMeta parent, Node node) {
|
587
|
38 |
super(parent, node);
|
|
39 |
callAntTargetVisitor();
|
|
40 |
}
|
|
41 |
|
|
42 |
public List<String> getExecTargets() {
|
|
43 |
return antcallTargets;
|
|
44 |
}
|
|
45 |
|
|
46 |
public List<String> getLogs() {
|
|
47 |
return logs;
|
|
48 |
}
|
|
49 |
|
|
50 |
public List<String> getSignals() {
|
|
51 |
return signals;
|
|
52 |
}
|
|
53 |
|
|
54 |
public List<String> getExecutables() {
|
|
55 |
return executables;
|
|
56 |
}
|
|
57 |
|
628
|
58 |
private void callAntTargetVisitor() {
|
587
|
59 |
// Add antcall/runtarget dependencies
|
|
60 |
antcallTargets = new ArrayList<String>();
|
|
61 |
logs = new ArrayList<String>();
|
|
62 |
signals = new ArrayList<String>();
|
|
63 |
executables = new ArrayList<String>();
|
|
64 |
|
|
65 |
Visitor visitorTarget = new AntTargetVisitor(antcallTargets, logs, signals, executables);
|
|
66 |
getNode().accept(visitorTarget);
|
|
67 |
}
|
|
68 |
|
|
69 |
private class AntTargetVisitor extends VisitorSupport {
|
|
70 |
private List<String> targetList;
|
|
71 |
private List<String> logList;
|
|
72 |
private List<String> signalList;
|
|
73 |
private List<String> executableList;
|
|
74 |
|
|
75 |
public AntTargetVisitor(List<String> targetList, List<String> logList, List<String> signalList,
|
|
76 |
List<String> executableList) {
|
|
77 |
this.targetList = targetList;
|
|
78 |
this.logList = logList;
|
|
79 |
this.signalList = signalList;
|
|
80 |
this.executableList = executableList;
|
|
81 |
}
|
|
82 |
|
|
83 |
@Override
|
|
84 |
public void visit(Element node) {
|
|
85 |
String name = node.getName();
|
|
86 |
if (name.equals("antcall") || name.equals("runtarget")) {
|
|
87 |
String text = node.attributeValue("target");
|
|
88 |
targetList.add(text);
|
|
89 |
}
|
|
90 |
|
|
91 |
if (!name.equals("include") && !name.equals("exclude")) {
|
|
92 |
String text = node.attributeValue("name");
|
|
93 |
addLog(text);
|
|
94 |
text = node.attributeValue("output");
|
|
95 |
addLog(text);
|
|
96 |
text = node.attributeValue("value");
|
|
97 |
addLog(text);
|
|
98 |
text = node.attributeValue("log");
|
|
99 |
addLog(text);
|
|
100 |
text = node.attributeValue("line");
|
|
101 |
addLog(text);
|
|
102 |
text = node.attributeValue("file");
|
|
103 |
addLog(text);
|
|
104 |
}
|
|
105 |
|
|
106 |
if (name.endsWith("signal") || name.endsWith("execSignal")) {
|
628
|
107 |
String signalid = node.attributeValue("name");
|
587
|
108 |
|
|
109 |
if (signalList != null) {
|
|
110 |
signalList.add(signalid);
|
|
111 |
}
|
|
112 |
}
|
|
113 |
|
|
114 |
if (name.equals("exec") || name.equals("preset.exec")) {
|
|
115 |
String text = node.attributeValue("executable");
|
|
116 |
executableList.add(text);
|
|
117 |
log("Executable: " + text, Project.MSG_DEBUG);
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
private void addLog(String text) {
|
|
122 |
if (text != null && logList != null) {
|
|
123 |
for (String log : text.split(" ")) {
|
628
|
124 |
String fulllogname = log;
|
587
|
125 |
if (!logList.contains(log) && (fulllogname.endsWith(".log") || fulllogname.endsWith(".html"))) {
|
|
126 |
log = log.replace("--log=", "");
|
|
127 |
logList.add(log);
|
|
128 |
}
|
|
129 |
}
|
|
130 |
}
|
|
131 |
}
|
|
132 |
}
|
|
133 |
}
|