color coded console logger for AntRunner? [message #291762] |
Thu, 22 September 2005 12:14 |
Eclipse User |
|
|
|
Hi All-
I managed to hook up a console logger to my AntRunner process so I now get
the ANT output logged to the console window, however it's all displayed in
black text. I would like the text to be color coded like it is if you run
an ANT script from within Eclipse. I've been digging through PDE code and
thus far have not found the right combination of things to get this to work.
Can anyone provide guidance?
Some code snippets (the console logger stuff I found in the newsgroups) on
how things are working:
AntRunner ant = new AntRunner();
ant.setBuildFileLocation(buildScript.getAbsolutePath());
ant.setArguments("-Dmessage=Building");
ant.addBuildLogger("foo.AntConsoleLogger"); // class is in fooant.jar
public class AntConsoleLogger extends DefaultLogger {
/**
* the message console stream used to output to the console view
*/
private MessageConsoleStream consoleStream = null;
/**
* Constructor
*/
public AntConsoleLogger() {
MessageConsole myConsole = findANTConsole("Ant Build");
consoleStream = myConsole.newMessageStream();
}
/**
* Logs messages from ANT to the console stream.
*/
protected void log(String message) {
consoleStream.println(message);
}
public static MessageConsole findANTConsole(String name) {
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
IConsole[] existing = conMan.getConsoles();
for (int i = 0; i < existing.length; i++) {
if (name.equals(existing[i].getName())) {
return (MessageConsole) existing[i];
}
}
//no console found, so create a new one
MessageConsole myConsole = new MessageConsole(name, null);
conMan.addConsoles(new IConsole[] { myConsole });
return myConsole;
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02755 seconds