Belun
Belun

Reputation: 4169

Why can there be multiple goals in a phase?

I have been reading on Maven and I understand that phases contain goals (which belong to maven plugins), that a phase can have multiple goals and a plugin can expose multiple goals?

If you look at some Plugin Bindings, there is one plugin goal (one only), attached directly to a phase. It is true that you can customize, but why would you?

What is the purpose of this feature? Can anyone offer some examples?

Upvotes: 0

Views: 130

Answers (1)

Robert Scholte
Robert Scholte

Reputation: 12335

Maven knows about all the phases, but not about all the plugins and their goals in the world. So it is not exactly that phases contains goals, but the other way around: a plugin goal is bound to a specific phase.

For example: there are several plugins which can do some validation before building the project, like the Maven Enforcer Plugin and maybe your custom-validation-plugin. Both goals needs to be executed during validation, so you bind them to that phase.

Maven defines about 20 phases, so simple projects often have indeed just 1 plugin bound to a phase, but as things get complexer, it is very normal to bind multiple plugins to 1 phase.

Upvotes: 1

Related Questions