1/3/2017 - 11:14 AM

Maven >> Lifecycle vs Phase vs Plugin vs Goal

Maven >> Lifecycle vs Phase vs Plugin vs Goal

A Maven lifecycle is an (abstract) concept that covers all steps (or better: all the steps the Maven designers decided to support) that are expected to occur in a project's development lifetime. These steps (or stages) are called phases in Maven terminology.

A Maven plugin is a container for/supplier of goals. Code implemented in goals is the real workhorse. (Maven in its core itself is just managing plugins and executing goals). Each of a plugin's goals can be assigned/bound to any of the lifecycle phases.

When invoking mvn <phase> Maven passes all phases (every time) and executes all goals (supplied by plugins) that have been bound to any of the phases prior and up to (and including) the given phase. If there is a phase with no goal bound to it nothing is done. But the phase is passed nevertheless.

I.e. you can't "'insert' additional phases" into one of Maven's built-in lifecycles. They are already there, always! You could develop your own lifecycle with its own phases but that's far beyond of simply using Maven as it is.

Phases called "pre-install" or "post-package" do not exist.