This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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 ?
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
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.