How to delegate the execution to other Mojos?

2009-11-11 Thread Gajo Csaba

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-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Re: How to delegate the execution to other Mojos?

2009-11-11 Thread Stephen Connolly
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 csaba.g...@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-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org



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



Re: How to delegate the execution to other Mojos?

2009-11-11 Thread Gajo Csaba

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 csaba.g...@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-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org





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

  



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



Re: How to delegate the execution to other Mojos?

2009-11-11 Thread Stephen Connolly
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 csaba.g...@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 csaba.g...@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-unsubscr...@maven.apache.org
 For additional commands, e-mail: users-h...@maven.apache.org




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




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