Tsuyoshi Ito wrote:
Hi Wayne
Thanks for the answer, obviously my question wasn't clear enough: I
read that mojos are components, how do I get such a component injected
within another mojo?
You do not. As Wayne pointed out, you can reuse code that is shared in a
common library, but not the Mojo itself. While it is *technically*
possible, you will screw up the Maven build in a very subtile way: Every
plugin is loaded once and only once (even in a multi-project build) - may
it be declared by the user (with a special version) or by your plugin as
dependency (with probably a different version). Depending on the build
order (especially in a multi-project) the plugin is loaded in one of the
versions above - however, you can never guarantee that those two plugin
versions are compatible (especially regarding the plugin configuration).
A Mojo is much more than just a goal in Maven, it is a component
managed by Plexus that can include references to other Plexus
components.
From maven definitive guide, chapter 17.2.4. What is a Plugin?
Extract the method to a utility class/jar/artifact which you can
depend on independently of your mojos, and then call it from each
mojo. And then, yes, you'll need to declare each plugin in your pom.
- Jörg
-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org