1

I don't know if this is actually possible, but can I take complete control over logging from inside a Maven Mojo? With complete control I mean that only messages from my Mojo are logged or that I can decide wether a given message shall be logged.

The context is that I'm using the maven-scm-plugin in my plugin to do some SCM action and it floods the log with

[INFO] Executing: cmd.exe /X /C "svn --non-interactive update D:\..."
[INFO] Working directory: D:\...

while my own messages get lost and are hard to notice.

After my Mojo finishes, logging can, and should, return to normal.

I tried to use setLog( Log ) to inject an own logger but that way I only get hold of my own messages. The instance of ScmManager I use to access maven-scm-plugin doesn't seem to have an appropiate method as well.

Thanks for your help!

Patrick Bergner
  • 623
  • 8
  • 23
  • I did not understand if you succeed at injecting your own logger (if you did, I guess it didn't work as expected). Can you clarify? – Pascal Thivent May 06 '10 at 06:59
  • I succeeded with injecting it but the logging of scm-plugin is not piped through the injected logger (i.e., the "global" Maven logger is not replaced by the injected one). Seems as if the "scope" of the injected logger is limited to my Mojo. – Patrick Bergner May 06 '10 at 07:05
  • Why would you like to control the logging output of other Plugins ? And in which way do you use the maven-scm-plugin in your own plugin, may be you can explain this a little bit more? – khmarbaise May 06 '10 at 08:08
  • I'm using the SCM plugin to fetch files from multiple SVN repositories. Each checkout produces the aforementioned two lines of [INFO] log output. I'd like my plugin to produce a decent amount of logging output but the about 10 lines I produce easily drown in the 100+ two liners the SCM plugin produces. – Patrick Bergner May 06 '10 at 08:44
  • Why are you trying that? I think this should be done by an CI Server instead. That's not the maven way... – khmarbaise May 06 '10 at 08:51
  • The plugin is a POM preprocessor that dynamically creates Maven projects from a release descriptor. The descriptor contains information about what modules a project consists of, where they are located in the SCM repo, which dependency versions they use, etc. The preprocessor checks out the modules according to the descriptor and then creates the POMs for the modules and the whole project. That way, it's easy to assemble projects without having to write a POM for each project and to check out all modules by hand. It's kind of what Antmod (http://www.antmod.net/) does for Ant builds. – Patrick Bergner May 06 '10 at 09:17

1 Answers1

2

You can't really control the level of log output of an other plugin than your own (only via -X). Only if you change the code of the other plugins.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • That's too bad but I already thought so. Thanks for clearing that up! I gave further details about how I use the SCM plugin beneath your comment to the initial question. – Patrick Bergner May 06 '10 at 08:46