What is Build Lifecycle?

What is Build Lifecycle?

A Build Lifecycle is a well-defined phase sequence that defines the order in which the objectives must be achieved. This stage in the life cycle indicates a stage. For example, the following sequence of steps is part of a typical Maven Build Lifecycle.

Pre- and post-phases are always available to log goals that must take place before or after a certain phase.

When Maven begins to construct a project, he proceeds through a predetermined phase sequence and implements recorded goals for each phase.

Maven has three standard life-cycles –

  • clean
  • default(or build)
  • site

A goal is a particular task that contributes to the construction and management. It can be bound to zero or more construction phases, and a target not constrained by any construction phase could be accomplished by direct invocation outside the build life cycle.

The order in which the goal(s) are invoked and the construction stage(s). Take the command below, for example. The clean arguments and package are construction steps, whereas the copy dependencies are a target.

mvn clean dependency:copy-dependencies package This is the first clean phase, followed by the copy-dependency target, and ultimately the paquet phase.

Clean Lifecycle

Maven invokes the clean lifecycle consisting of the next phases when we execute mvn post-clean control.

  • pre-clean
  • clean
  • post-clean

Maven's clean target (clean: clean) is linked to the clean lifecycle stage. Your clean:cleangoal removes the output from the built directory by deleting it. So Maven deletes the build directory when executing an mvn clean command.

This behavior can be customized by specifying goals in any clean life cycle stages.