Plexus components should not know anything specific about the Maven environment. Maven is also a session-based system so it's almost always better to make a threadsafe component which holds no state and takes in what it needs in a method to operate.

From the Mojo take the MavenSession, grab what you need from the session and pass it into the threadsafe component that you've injected. You can avoid components with state most of the time and if you can you should. This also makes testing easier as you can just create a PlexusTestCase, lookup your component and pass in test data.

Constructor and FactoryBean injection work in later versions of Plexus but not in the 2.0.x version so stick with threadsafe components.

On 26-Nov-08, at 2:41 AM, nicolas de loof wrote:

As my plugin is becoming complex, I've splitted it into plexus components,
injected in the Mojo.I need this plexus component to acces
the localRepository. How to configure the @component annotation ???
Same issue to get the MavenProject.

Nicolas

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------

In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.

  -- Jacques Ellul, The Technological Society


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to