开发者

How to intercept log messages from a Maven Mojo in a m2e plugin

I have a special JavaScript maven plugin which validates/compresses JavaScript sources from /src/main/javascript and stores it into /target/scripts. In Eclipse 3.6 with m2e 0.x this worked perfectly because this plugin is executed during the process-resources phase. So everytime I save a file in Eclipse the project is compiled. When the validator finds a problem then this problem is logged as an error to the maven console.

Now with Eclispe 3.7 and the new m2e 1.x this no longer works because a special connector is needed to process this plugin. It is also possible to configure a lifecycle mapping so this plugin is simply executed. But when I do this I have no logging messages any longer. I only get an error marker in the POM when a Javascript error was found. This isn't really useful. So I'm trying to write a m2e plugin which executes the maven plugin and then displays the errors nicely in Eclipse. But I'm a total noob when it comes to eclipse plugin programming. My participant currently looks like this:

public class Participant extends MojoExecutionBuildParticipant
{
    public Participant(final MojoExecution execution)
    {
        super(execution, true);
    }

    @Override
    public Set<IProject> build(final int kind, final IProgressMonitor monitor)
        throws Exception
    {
        final Set<IProject> result = super.build(ki开发者_运维百科nd, monitor);
        return result;
    }
}

The build method is correctly called and the maven plugin is also correctly executed. But with this simple approach I even don't get any error markers when the plugin fails. So how can I hook into the maven execution now to intercept build errors and how can I display them in Eclipse? It would be sufficient when the error log messages simply are displayed in the maven console again but it would be even cooler when I could create real error markers pointing to the real file locations (Which I could parse from the maven plugin logging).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜