You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Laird Nelson <lj...@gmail.com> on 2011/09/07 21:20:57 UTC

Plugin insantiation: once per execution? Once per build?

What is the lifespan of a Mojo?

Is a new one created for each execution?  Is it discarded thereafter, or
does Maven retain a reference to it?

Or is only one created and then reconfigured/reset?

I didn't find any obvious documentation explaining this, but as usual my
apologies if I've overlooked something.

Thanks,
Laird

-- 
http://about.me/lairdnelson

Re: Plugin insantiation: once per execution? Once per build?

Posted by Laird Nelson <lj...@gmail.com>.
On Thu, Sep 8, 2011 at 2:27 AM, Baptiste MATHUS <ml...@batmat.net> wrote:

> Hi, I suppose that you ask that.because you're writing a mojo yourself. I
> don't know the answer but it seems to me it would quite simple to check it
> by code: just add a log in your constructor and see if displays once or
> many
> times.
>

Right; I want to know what is *intended* versus what I can observe
happening.  Is the intended behavior what happens?  Or can the Maven
developers decide to change the plugin lifecycle out from under me?  IMHO
any plugin system should be governed by a contract.


> By the way, also think abt "thread-safing" your code to prevent having bugs
> using -T switch.
>

I'd like my plugin to be as thread-safe as possible, but to do that I need
to know its lifecycle.  Thanks!

Best,
Laird

-- 
http://about.me/lairdnelson

Re: Plugin insantiation: once per execution? Once per build?

Posted by Baptiste MATHUS <ml...@batmat.net>.
Hi, I suppose that you ask that.because you're writing a mojo yourself. I
don't know the answer but it seems to me it would quite simple to check it
by code: just add a log in your constructor and see if displays once or many
times.

By the way, also think abt "thread-safing" your code to prevent having bugs
using -T switch.

Cheers
Le 7 sept. 2011 21:21, "Laird Nelson" <lj...@gmail.com> a écrit :
> What is the lifespan of a Mojo?
>
> Is a new one created for each execution? Is it discarded thereafter, or
> does Maven retain a reference to it?
>
> Or is only one created and then reconfigured/reset?
>
> I didn't find any obvious documentation explaining this, but as usual my
> apologies if I've overlooked something.
>
> Thanks,
> Laird
>
> --
> http://about.me/lairdnelson