Maven : How mojo executions are ordered in a phase

Note that I’m switching to english for this blog entry but I’m not yet sure it will be always the case … I’m testing :-)
After reporting a regression in M2 -> M3 upgrade (see MNG-4975) I discovered I didn’t understood how is computed the execution order of mojos in a Maven phase (Thanks Benjamin Bentmann).

As you know Maven is built around the notion of build lifecycle. You call a maven phase in your project and Maven will execute all phases to go up to the one you asked. For each phase it will execute a set of Mojos bound on it.
The question is what happens if several mojos (from the same or different plugins) are bound to the same phase. In which order are they executed ?
The reply is : in the order of declaration in the POM. Thus the important thing to understand is that the id used for an execution to bind a mojo to a phase isn’t used to compute this order.
And what about inheritance ? Executions of the parent are done before the child executions.
Our team will add a clear documentation about this in plugins configuration documentation. What is important to understand it is that there is no magic in Maven (just few holes in the documentation and we are doing our best to fill them).

GD Star Rating
GD Star Rating
Maven : How mojo executions are ordered in a phase, 6.5 out of 10 based on 2 ratings

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>