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!
I feel there must be far better ways to do what I do... that makes learning even funnier
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
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.