You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Gajo Csaba <cs...@cosylab.com> on 2009/11/11 10:38:45 UTC

How to delegate the execution to other Mojos?

Hello,

I would like to create a maven plugin, which would delegate to other 
plugins based on parameters. Something like mvn mymojo:dotask -Dtask=<xxx>

and then in the "dotask" mojo I would see what the value of task is, and 
if it's xxx then execute Mojo1, if it's yyy then Mojo2 etc...

How can I do this?

Thanks, Csaba




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


Re: How to delegate the execution to other Mojos?

Posted by Stephen Connolly <st...@gmail.com>.
I would suggest that maybe profiles would be better suited... if you specify
the defaultGoal in the profile it gets even easier...

But to be honest, you are going against *The Maven Way™*

This is usually (but not always) a sign that you will soon be fighting
Maven, and that is a fight that you can only win with the loss of all of
your hair ;-)

-Stephen

2009/11/11 Gajo Csaba <cs...@cosylab.com>:
> OK so my use case would be
>
> mvn do-task -Dtask=xxx
>
> Do you suggest I change that into
>
> mvn do-task-xxx?
>
> Regards, Csaba
>
>
> Stephen Connolly wrote:
>>
>> Short answer: Don't
>>
>> Long answer: for a mojo to extend another maven plugin, it will need
>> to depend on that maven plugin.  The maven plugin classloader only
>> loads a plugin once, and the first version loaded is the version used
>> forever more (until maven exits).  When a newer version of the plugin
>> you depend on is released, you will either force the older version on
>> anyone using your plugin, or the newer version will be forced on you.
>> In either case, the build will probably be broken in a hard to figure
>> out way
>>
>> -Stephen
>>
>> 2009/11/11 Gajo Csaba <cs...@cosylab.com>:
>>
>>>
>>> Hello,
>>>
>>> I would like to create a maven plugin, which would delegate to other
>>> plugins
>>> based on parameters. Something like mvn mymojo:dotask -Dtask=<xxx>
>>>
>>> and then in the "dotask" mojo I would see what the value of task is, and
>>> if
>>> it's xxx then execute Mojo1, if it's yyy then Mojo2 etc...
>>>
>>> How can I do this?
>>>
>>> Thanks, Csaba
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: How to delegate the execution to other Mojos?

Posted by Gajo Csaba <cs...@cosylab.com>.
OK so my use case would be

mvn do-task -Dtask=xxx

Do you suggest I change that into

mvn do-task-xxx?

Regards, Csaba


Stephen Connolly wrote:
> Short answer: Don't
>
> Long answer: for a mojo to extend another maven plugin, it will need
> to depend on that maven plugin.  The maven plugin classloader only
> loads a plugin once, and the first version loaded is the version used
> forever more (until maven exits).  When a newer version of the plugin
> you depend on is released, you will either force the older version on
> anyone using your plugin, or the newer version will be forced on you.
> In either case, the build will probably be broken in a hard to figure
> out way
>
> -Stephen
>
> 2009/11/11 Gajo Csaba <cs...@cosylab.com>:
>   
>> Hello,
>>
>> I would like to create a maven plugin, which would delegate to other plugins
>> based on parameters. Something like mvn mymojo:dotask -Dtask=<xxx>
>>
>> and then in the "dotask" mojo I would see what the value of task is, and if
>> it's xxx then execute Mojo1, if it's yyy then Mojo2 etc...
>>
>> How can I do this?
>>
>> Thanks, Csaba
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>   


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


Re: How to delegate the execution to other Mojos?

Posted by Stephen Connolly <st...@gmail.com>.
Short answer: Don't

Long answer: for a mojo to extend another maven plugin, it will need
to depend on that maven plugin.  The maven plugin classloader only
loads a plugin once, and the first version loaded is the version used
forever more (until maven exits).  When a newer version of the plugin
you depend on is released, you will either force the older version on
anyone using your plugin, or the newer version will be forced on you.
In either case, the build will probably be broken in a hard to figure
out way

-Stephen

2009/11/11 Gajo Csaba <cs...@cosylab.com>:
> Hello,
>
> I would like to create a maven plugin, which would delegate to other plugins
> based on parameters. Something like mvn mymojo:dotask -Dtask=<xxx>
>
> and then in the "dotask" mojo I would see what the value of task is, and if
> it's xxx then execute Mojo1, if it's yyy then Mojo2 etc...
>
> How can I do this?
>
> Thanks, Csaba
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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