Writing my own mojo - how do I specify a default goal?
Hi! I am trying to write my own Maven plugin. I want to be able to specify it in a build without specifying any additional parameters. I don't seem to find any example after some googling. In a perfect world, I would like to write my pom like this: se.somath publisher-plugin 1.0-SNAPSHOT That is, just specify that this plugin should be used. At the moment I have to specify it like this: se.somath publisher-plugin 1.0-SNAPSHOT process Currently I have just one goal and it doesn't take any parameters. This question might be better to send to the developers list, but I don't follow that list and I assume that there are some mojo developers following this list that might be able to assist me. Thomas -- Thomas Sundberg M. Sc. in Computer Science Mobile: +46 70 767 33 15 Blog: http://thomassundberg.wordpress.com/ Twitter: @thomassundberg Better software through faster feedback - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Writing my own mojo - how do I specify a default goal?
You cannot have that, you need to bind the goal at least (and goal usually have a "preferred" phase it will bind to). Plugin that does not have execution defined but it still executes (as you say you'd want) is usually bound to lifecycle of the packaging in it's lifecycle mapping. So, unless you write your own packaging (I doubt this is what you need), you are left to declare plugin _with_ executions. Thanks, ~t~ On Sat, Jul 21, 2012 at 10:13 AM, Thomas Sundberg wrote: > Hi! > > I am trying to write my own Maven plugin. I want to be able to specify > it in a build without specifying any additional parameters. I don't > seem to find any example after some googling. In a perfect world, I > would like to write my pom like this: > > > > > se.somath > publisher-plugin > 1.0-SNAPSHOT > > > > > That is, just specify that this plugin should be used. > > At the moment I have to specify it like this: > > > > > se.somath > publisher-plugin > 1.0-SNAPSHOT > > > > process > > > > > > > > Currently I have just one goal and it doesn't take any parameters. > > This question might be better to send to the developers list, but I > don't follow that list and I assume that there are some mojo > developers following this list that might be able to assist me. > > Thomas > > -- > Thomas Sundberg > M. Sc. in Computer Science > > Mobile: +46 70 767 33 15 > Blog: http://thomassundberg.wordpress.com/ > Twitter: @thomassundberg > > Better software through faster feedback > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > >
Re: Writing my own mojo - how do I specify a default goal?
Hi! On 21 July 2012 10:45, Tamás Cservenák wrote: > You cannot have that, you need to bind the goal at least (and goal usually > have a "preferred" phase it will bind to). > Plugin that does not have execution defined but it still executes (as you > say you'd want) is usually bound to lifecycle of the packaging in it's > lifecycle mapping. So, unless you write your own packaging (I doubt this is > what you need), you are left to declare plugin _with_ executions. This is what I want. I want to package my plugin so that it knows which phase to execute in. It is also ok for my use case if the execution phase is impossible to change. But it is either a well guarded secret how to package a plugin so it has knowledge about when it should be executed or impossible. So, assuming that it is a matter of packaging, does anybody have any good pointers I could look at? /Thomas > > Thanks, > ~t~ > > On Sat, Jul 21, 2012 at 10:13 AM, Thomas Sundberg wrote: > >> Hi! >> >> I am trying to write my own Maven plugin. I want to be able to specify >> it in a build without specifying any additional parameters. I don't >> seem to find any example after some googling. In a perfect world, I >> would like to write my pom like this: >> >> >> >> >> se.somath >> publisher-plugin >> 1.0-SNAPSHOT >> >> >> >> >> That is, just specify that this plugin should be used. >> >> At the moment I have to specify it like this: >> >> >> >> >> se.somath >> publisher-plugin >> 1.0-SNAPSHOT >> >> >> >> process >> >> >> >> >> >> >> >> Currently I have just one goal and it doesn't take any parameters. >> >> This question might be better to send to the developers list, but I >> don't follow that list and I assume that there are some mojo >> developers following this list that might be able to assist me. >> >> Thomas >> >> -- >> Thomas Sundberg >> M. Sc. in Computer Science >> >> Mobile: +46 70 767 33 15 >> Blog: http://thomassundberg.wordpress.com/ >> Twitter: @thomassundberg >> >> Better software through faster feedback >> >> - >> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org >> For additional commands, e-mail: users-h...@maven.apache.org >> >> -- Thomas Sundberg M. Sc. in Computer Science Mobile: +46 70 767 33 15 Blog: http://thomassundberg.wordpress.com/ Twitter: @thomassundberg Better software through faster feedback - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Writing my own mojo - how do I specify a default goal?
I'd start with http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-intro.html And have a good look at http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-plugins-lifecycle.html#writing-plugins-sect-override-default-lifecycle -Robert Op Sat, 21 Jul 2012 17:13:46 +0200 schreef Thomas Sundberg : Hi! On 21 July 2012 10:45, Tamás Cservenák wrote: You cannot have that, you need to bind the goal at least (and goal usually have a "preferred" phase it will bind to). Plugin that does not have execution defined but it still executes (as you say you'd want) is usually bound to lifecycle of the packaging in it's lifecycle mapping. So, unless you write your own packaging (I doubt this is what you need), you are left to declare plugin _with_ executions. This is what I want. I want to package my plugin so that it knows which phase to execute in. It is also ok for my use case if the execution phase is impossible to change. But it is either a well guarded secret how to package a plugin so it has knowledge about when it should be executed or impossible. So, assuming that it is a matter of packaging, does anybody have any good pointers I could look at? /Thomas Thanks, ~t~ On Sat, Jul 21, 2012 at 10:13 AM, Thomas Sundberg wrote: Hi! I am trying to write my own Maven plugin. I want to be able to specify it in a build without specifying any additional parameters. I don't seem to find any example after some googling. In a perfect world, I would like to write my pom like this: se.somath publisher-plugin 1.0-SNAPSHOT That is, just specify that this plugin should be used. At the moment I have to specify it like this: se.somath publisher-plugin 1.0-SNAPSHOT process Currently I have just one goal and it doesn't take any parameters. This question might be better to send to the developers list, but I don't follow that list and I assume that there are some mojo developers following this list that might be able to assist me. Thomas -- Thomas Sundberg M. Sc. in Computer Science Mobile: +46 70 767 33 15 Blog: http://thomassundberg.wordpress.com/ Twitter: @thomassundberg Better software through faster feedback - 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: Writing my own mojo - how do I specify a default goal?
>> Plugin that does not have execution defined but it still executes (as you >> say you'd want) is usually bound to lifecycle of the packaging in it's >> lifecycle mapping. So, unless you write your own packaging (I doubt this is >> what you need), you are left to declare plugin _with_ executions. > > But it is either a well guarded secret how to package a plugin so it > has knowledge about when it should be executed or impossible. There is no great conspiracy at work here. You simply fail to understand what is meant by the term "packaging." Tamás is not saying you need to package your plugin a particular way for this to work. He is literally talking about Maven's concept of a package (jar, war, ear, pom, etc) and how that determines the lifecycle which will be used and thus which plugins are bound to the build. Read more here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Packaging If you really want to do this, read Robert's links. It is nontrivial stuff but can certainly be done if this is truly what you require. Most people find this to be way more than they need and resort to providing a couple extra lines of configuration in their plugin declarations instead. Wayne - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Writing my own mojo - how do I specify a default goal?
On 21 July 2012 20:51, Wayne Fay wrote: >>> Plugin that does not have execution defined but it still executes (as you >>> say you'd want) is usually bound to lifecycle of the packaging in it's >>> lifecycle mapping. So, unless you write your own packaging (I doubt this is >>> what you need), you are left to declare plugin _with_ executions. >> >> But it is either a well guarded secret how to package a plugin so it >> has knowledge about when it should be executed or impossible. > > There is no great conspiracy at work here. You simply fail to > understand what is meant by the term "packaging." Tamás is not saying > you need to package your plugin a particular way for this to work. He > is literally talking about Maven's concept of a package (jar, war, > ear, pom, etc) and how that determines the lifecycle which will be > used and thus which plugins are bound to the build. Yes, that was the part I failed to understand. > > Read more here: > http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Packaging > > If you really want to do this, read Robert's links. It is nontrivial > stuff but can certainly be done if this is truly what you require. I have gotten it to work now and while preparing dinner I suddenly understood what Tamas meant. The pointers Robert gave me was good and got me in the right direction. > Most people find this to be way more than they need and resort to > providing a couple extra lines of configuration in their plugin > declarations instead. You are probably right. Adding the extra configuration makes it easier to execute your own Mojo, but for some reasons I didn't want them there. I ended up with an additional true instead. I guess that's something I have to live with. Thanks for your help! Thomas -- Thomas Sundberg M. Sc. in Computer Science Mobile: +46 70 767 33 15 Blog: http://thomassundberg.wordpress.com/ Twitter: @thomassundberg Better software through faster feedback - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org