%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
nl.toolforge.karma.core.cmd.util.AntLogger |
|
|
1 | /* |
|
2 | Karma core - Core of the Karma application |
|
3 | Copyright (C) 2004 Toolforge <www.toolforge.nl> |
|
4 | ||
5 | This library is free software; you can redistribute it and/or |
|
6 | modify it under the terms of the GNU Lesser General Public |
|
7 | License as published by the Free Software Foundation; either |
|
8 | version 2.1 of the License, or (at your option) any later version. |
|
9 | ||
10 | This library is distributed in the hope that it will be useful, |
|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 | Lesser General Public License for more details. |
|
14 | ||
15 | You should have received a copy of the GNU Lesser General Public |
|
16 | License along with this library; if not, write to the Free Software |
|
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | */ |
|
19 | package nl.toolforge.karma.core.cmd.util; |
|
20 | ||
21 | import nl.toolforge.karma.core.cmd.Command; |
|
22 | import nl.toolforge.karma.core.cmd.event.MessageEvent; |
|
23 | import nl.toolforge.karma.core.cmd.event.SimpleMessage; |
|
24 | import org.apache.tools.ant.BuildEvent; |
|
25 | import org.apache.tools.ant.DefaultLogger; |
|
26 | ||
27 | import java.util.HashSet; |
|
28 | import java.util.Iterator; |
|
29 | import java.util.Set; |
|
30 | ||
31 | /** |
|
32 | * @author D.A. Smedes |
|
33 | * @version $Id: AntLogger.java,v 1.7 2004/11/10 23:53:09 asmedes Exp $ |
|
34 | */ |
|
35 | public class AntLogger extends DefaultLogger { |
|
36 | ||
37 | public static final int LEFT_COLUMN_SIZE = 16; |
|
38 | ||
39 | // Specific messages we want to capture |
|
40 | // |
|
41 | 0 | private static Set messagePrefixes = null; |
42 | ||
43 | // Specific tasks we want to capture |
|
44 | // |
|
45 | 0 | private static Set taskNames = null; |
46 | ||
47 | 0 | private Command command = null; |
48 | ||
49 | static { |
|
50 | ||
51 | 0 | messagePrefixes = new HashSet(); |
52 | ||
53 | // "<javac> Compiling ..." |
|
54 | // |
|
55 | 0 | messagePrefixes.add("Compiling"); |
56 | ||
57 | 0 | taskNames = new HashSet(); |
58 | 0 | taskNames.add("javadoc"); // <javadoc> |
59 | 0 | taskNames.add("javac"); // <javac> |
60 | 0 | } |
61 | ||
62 | 0 | public AntLogger(Command command) { |
63 | 0 | this.command = command; |
64 | 0 | } |
65 | ||
66 | private boolean map(BuildEvent event) { |
|
67 | 0 | if (event.getTask() != null) { |
68 | 0 | if (taskNames.contains(event.getTask().getTaskName())) { |
69 | 0 | return true; |
70 | } |
|
71 | } |
|
72 | ||
73 | 0 | for (Iterator i = messagePrefixes.iterator(); i.hasNext();) { |
74 | 0 | if (event.getMessage().startsWith((String) i.next())) { |
75 | 0 | return true; |
76 | } |
|
77 | } |
|
78 | 0 | return false; |
79 | } |
|
80 | ||
81 | /** |
|
82 | * Filters out very specific ant event messages and prints them. Very specific. Not all of the stuff that you |
|
83 | * normally get. |
|
84 | * |
|
85 | * @param event |
|
86 | */ |
|
87 | public void messageLogged(BuildEvent event) { |
|
88 | ||
89 | 0 | int priority = event.getPriority(); |
90 | ||
91 | 0 | if (priority <= msgOutputLevel) { |
92 | 0 | if (map(event)) { |
93 | 0 | command.getCommandResponse().addEvent(new MessageEvent(command, class="keyword">new SimpleMessage(event.getMessage()))); |
94 | } |
|
95 | } |
|
96 | 0 | } |
97 | ||
98 | /** |
|
99 | * Overridden version. |
|
100 | * |
|
101 | * @param event |
|
102 | */ |
|
103 | 0 | public void targetStarted(BuildEvent event) {} |
104 | ||
105 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |