Meaningless Drivel is fun!*
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven MOJO ContextEnabled Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven MOJO ContextEnabled" Watch "Maven MOJO ContextEnabled" New topic
Author

Maven MOJO ContextEnabled

Louis Brown
Greenhorn

Joined: Nov 13, 2011
Posts: 5
Hello,

while developing maven MOJO I have noticed that AbstractMojo, contains "pluginContext" map, which supposedly can be set before running MOJOs. What I can't figure out, how does one need to properly set it up for usage ? Maybe someone who had experience with it could help me on this one ?

Thanks
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

I don't you you have to do anything to set it, I think that Maven will set it for you. Have you tried getting it to see what it contains?


JBoss In Action
Louis Brown
Greenhorn

Joined: Nov 13, 2011
Posts: 5
By default it contains an empty map. I was wondering maybe you can specify some options in PLUGIN POM configuration, to load some values or inject singleton beans into it. I have tried setting map directly within the MOJO, although when MOJO for one modlue completes and begins for another, a new empty MAP is set. Maybe this pluginContext is a lie
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Like much open source code, the documentation for how to build Maven plugins is rather skimpy. <whine>It is as if the developers of the code either don't want you using their code, or they figure that only if you are willing to study their code, and understand it intimately, should you be allowed to use their code.</whine>

Personally, I have never had to make use of pluginContext. And I have written numerous plugins.

Anyway, here is what I would do to find out how it is used. I would edit the AbstractMojo class to print a stack trace anytime the pluginContext getter or setter is called. Then I would compile the class and replace it in the appropriate Maven JAR file, most likely Maven Core. (I do this so often, not for this class but other classes in Maven Core, that I have a pom.xml that does this for me - recompiles only the changed class and rebuilds the Core JAR replacing only the compiled class.) Then I would run some builds that make use of lots of plugins and see what I get. Examining the stack traces will lead to plugins that make use of pluginContext, and you can then look at the source code of those plugins to see how they are using it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maven MOJO ContextEnabled