• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Maven alternate/custom lifecycle

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to have a new lifecycle for Maven 2, in which I define my own phases. Does anybody know how to do this?

Do I need to introduce changes in the poms? Because I would like not to touch anything in my already working poms, just create a new custom lifecycle, with new phase for which I can create plugins, but avoiding changes in every pom IF POSSIBLE.

Thank you very much!

antonio
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would read Maven the Definitive Guide as a primer on how to start doing this.
 
Antonio Fornie
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes that's always one of my first references, but I didn't find what I want, I think it's not possible.

I can do something like the following, just in case anybody wants to know it. Maven installation brings a jar (uber) which defines the lifecycles in the file uber.jar/META-INF/plexus/components.xml. There you should define a knew lifecycle with its own id and own phases. Then you'll have to define default goals (plugin:goal) for each phase.

You can define goals already defined for other lifecycles, but you cannot repeat phase names. The problem is that even when I declare here that I will use MyPlugin:MyGoal in the phase MyPhase of a new custom lifecycle, I'll have to modify dozens of projects's pom.xml files if I want them to have the behavior they used to have for common phases in my phases. I mean, I can add this to components.xml

<id>my_lifecycle</id>
<phases>
<phase>my_deploy</phase>
</phases>
</lifecycle>

But not this

<id>my_lifecycle</id>
<phases>
<phase>deploy</phase>
</phases>
</lifecycle>

Because I'm using a phase name already used for default lifecycle: deploy.

My scenario is there are hundreds of projects that include a pom with lot of info about compilation, testing... AND DEPLOYMENT. But as it takes so long any of these phases, I want to create a custom lifecycle that just go directly to deploy phase (the same as default lifecycle but without phases prior to pdeployment), that way I can invoke the default lifecycle until install phase and leave it all prepared sometime before deployment, in order to be fast when it comes to actually deploy the app because it wouldn't go through previous phases.

Whith my solution I would have to mention the phase my_deploy in hundreds of pom.xml files as all of them have a lot of info related to deploy phase now... I think my best choice would be to invoke mvn deploy skipping all the previous phases.

I hope anybody found this topic worth reading. Best regards and thank you very much as always.

antonio
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Going out on a limb here, but maybe you can use a profile to execute the alternative behaviour in the same phase?
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic