You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by S....@abg.com.pl on 2006/08/22 18:40:33 UTC

Is there a way to access MavenSession, PlexusContainer from plugin?

Hi,

Is there a way to access MavenSession, PlexusContainer or any other object
from within pugin, that could give me acces to Lifecycle.

I need to create plugin that would stop executing other phases in current
project and let it go to the parent project depending on some circumstance.


Thanks
Sebastian Błoch

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Configuration Manager
ABG Ster-Projekt S.A.

ul. Domaniewska 41, bud. Taurus
02-672 Warszawa
tel.: (022) 33 76 787
kom.: +48 696 027 166
e-mail: S.Bloch@abg.com.pl
www.abg.com.pl


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Is there a way to access MavenSession, PlexusContainer from plugin?

Posted by Warpian <tk...@yahoo.com>.
I know this thread is old, but I was looking for the exact same answer and I
found a good solution so I thought I might as well share it.

If you are using the Maven embedder, getting a reference to the Plexus
container is really simple. Just search this forum.

However, If you work on a Maven plugin project, have Plexus instantiate a
custom Plexus component by injecting it into your Mojo (goal). A Plexus
custom component is implemented as a pojo java class annotated with
"@plexus.component role=...". Have your custom component class implement the
Plexus
"org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable"
interface. This interface functions much like a marker interface, telling
Plexus to feed to your component instance the Plexus context after
construction. That interface has one (callback) method named
"contextualize". Code example:
<pre>
    public void contextualize(Context context) throws ContextException {
        this.plexusContainer = (PlexusContainer)
context.get(PlexusConstants.PLEXUS_KEY);
    }
</pre>

The rest is obvious...

cheers,
Tom Kalmijn




S.Bloch wrote:
> 
> 
> Hi,
> 
> Is there a way to access MavenSession, PlexusContainer or any other object
> from within pugin, that could give me acces to Lifecycle.
> 
> I need to create plugin that would stop executing other phases in current
> project and let it go to the parent project depending on some
> circumstance.
> 
> 
> Thanks
> Sebastian Błoch
> 
> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Configuration Manager
> ABG Ster-Projekt S.A.
> 
> ul. Domaniewska 41, bud. Taurus
> 02-672 Warszawa
> tel.: (022) 33 76 787
> kom.: +48 696 027 166
> e-mail: S.Bloch@abg.com.pl
> www.abg.com.pl
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Is-there-a-way-to-access-MavenSession%2C-PlexusContainer-from-plugin--tp5929374p25989081.html
Sent from the Maven Developers mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org