Total Pageviews

Sunday, November 19, 2006

Using Maven Embedder and logging almost drove me nuts

I was recently experimenting with the maven embedder component (Version 2.0.4) to embed Maven into IDEA using the embedder API.

Somehow I called the setLogger(...) method AFTER I called maven.start(). This almost drove me crazy, because I didn't get any output. The trick is, to call the setLogger(...) method before a call to maven.start(), e.g. just like this (as described in the maven docs, see

MavenEmbedder maven = new MavenEmbedder();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
maven.setClassLoader( classLoader );
maven.setLogger( new MavenEmbedderConsoleLogger() );

It seems that it is currently (in Version 2.0.4) not possible to set the logger after the embedder was started.

Maybe this is helpful for others.

No comments:

Post a Comment