Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » AntRunner & BuildLogger
AntRunner & BuildLogger [message #721456] Thu, 01 September 2011 19:37 Go to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I'm having problems understanding how to configure AntRunner to write
its output to the Console.

I've added implemented a BuildLogger:
> package at.bestsolution.efxclipse.tooling.jdt.ui.internal.handler;
>
> import org.apache.tools.ant.DefaultLogger;
> import org.eclipse.ui.console.ConsolePlugin;
> import org.eclipse.ui.console.IConsole;
> import org.eclipse.ui.console.IConsoleManager;
> import org.eclipse.ui.console.MessageConsole;
> import org.eclipse.ui.console.MessageConsoleStream;
>
> public class AntLogger extends DefaultLogger {
> // the message console stream used to output to the console view
> // private MessageConsoleStream mConsoleStream = null;
>
> public AntLogger() {
> super();
> MessageConsole myConsole = findConsole("Some console name");
> // mConsoleStream = myConsole.newMessageStream();
> }
>
> protected void log(String message) {
> // mConsoleStream.println(message);
> }
>
> public static MessageConsole findConsole(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;
> }
> }

exported it into a .jar and registered this one using
org.eclipse.ant.core.extraClasspathEntries but now when running the
AntRunner I get a ClassCastException.

> !SUBENTRY 1 org.eclipse.ant.core 4 1 2011-09-01 21:34:39.061
> !MESSAGE at.bestsolution.efxclipse.tooling.jdt.ui.internal.handler.AntLogger which was specified to perform logging is not an instance of org.apache.tools.ant.BuildLogger.
> !STACK 0
> at.bestsolution.efxclipse.tooling.jdt.ui.internal.handler.AntLogger which was specified to perform logging is not an instance of org.apache.tools.ant.BuildLogger.
> at org.eclipse.ant.internal.core.ant.InternalAntRunner.createLogger(InternalAntRunner.java:749)
> at org.eclipse.ant.internal.core.ant.InternalAntRunner.addBuildListeners(InternalAntRunner.java:200)
> at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:570)
> at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:496)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.ant.core.AntRunner.run(AntRunner.java:378)

The problem is that the Logger is loaded through Class.forName() and so
there a 2 different BundleLogger.class-instance because there are 2
different classloaders.

Did I forget something to register?

Tom
Re: AntRunner &amp; BuildLogger [message #722997 is a reply to message #721456] Wed, 07 September 2011 11:51 Go to previous message
Gerald  is currently offline Gerald Friend
Messages: 5
Registered: April 2011
Junior Member
Have you found a solution for this?
I tried to set this with setCustomClasspath but now he don't know the Console classes
Greetings,
Gerald
Previous Topic:Changing UI language
Next Topic:getIndentPrefixes and getIndentPrefixesForTab return values
Goto Forum:
  


Current Time: Fri Apr 19 05:19:26 GMT 2024

Powered by FUDForum. Page generated in 0.02710 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top