Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] How to catch maven compilation errors in m2e plugin?

If you control the maven plugin, then BuildContext from susi-build-api
is the easiest way to associate problem markers with source files.

If you can't change the maven plugin, you can access maven build
problems from build participant using
getSession().getResult().getExceptions().

[1] https://github.com/sonatype/sisu-build-api

--
Regards,
Igor

On 11-07-21 6:22 PM, Klaus Reimer wrote:
Hello,

I wrote a maven plugin which compiles javascript files. This plugin is
executed in the "compile" phase and can generate error messages exactly
like the javac compiler plugin is doing it (By throwing a
CompilationFailureException which encapsulates an array of CompilerError
objects).

When I simply add a lifecycle mapping to let Eclipse execute this plugin
then I only get a "Compilation failure" error marker in the pom.xml when
my maven plugin found an error in the JavaScript files. This isn't
really helpful so I thought I could write a m2e plugin which could
process the error result of Maven and generate useful Eclipse error markers.

I created the m2e plugin, created a Configurator which connects a
Participant to the compile goal and this participant is even executed.
But now I'm stuck with this simple code (Which simply calls the build
method of the MojoExecutionBuildParticipant class:

public Set<IProject>  build(final int kind, final IProgressMonitor
monitor) throws Exception
{
     super.build(kind, monitor);
}

How can I access the maven build errors now and convert them to Eclipse
error markers? Or is this the wrong approach to solve my problem? Maybe
someone can push me in the right direction? Maybe there is already a
similiar m2e plugin out there I can learn from?



Back to the top