Note: this thread is about writing a custom Mojo, not using a plugin.
I maintain a testing plugin for Maven. Unfortunately, for almost a year now, I've let this particular unknown linger and I'd really like to know how to deal with it so that its users can have a simpler configuration.
Let's say we have two goals in our plugin:
prepare(phase: generate-sources)do(phase: compile)
I want to configure the do Mojo to require prepare to have been executed in the earlier phase of the build. However, nothing in the descriptor documentation suggests I can.
The user probably doesn't care or understand the point of the prepare goal, so I don't want to force them to specify it in their POM. Of course, I could execute the Mojo directly from do, but then the prepare goal will have run at a later phase than is intended.
(I looked into custom lifecycles, but that makes it appear that everyone who already has the prepare goal in their POMs will have it executed twice upon running do.)