Maven - Build LifeCycle

Introduction

A Build Lifecycle is a well-defined sequence of phases which define the order in which the goals are to be executed. Here phase represents a stage in life cycle. As an example, a typical Maven Build Lifecycle consists of following sequence of phases.

A Build Life cycle is Made Up of Phases:

Each of these build life cycles is defined by a different list of build phases, where in a build phase represents a stage in the life cycle.
Maven Build Lifecycle
Maven Build Lifecycle
For example, the default life-cycle comprises of the following phases :
Validate - validate the project is correct and all necessary information is available
Compile - compile the source code of the project
Test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
Package - take the compiled code and package it in its distributed format, such as a JAR.
Verify - run any checks on results of integration tests to ensure quality criteria are met
Install - install the package into the local repository, for use as a dependency in other projects locally
Deploy - done in the build environment, copies the final package to the remote repository for sharing with other developers and projects.

Two non-default phases are clean and site

Given the life cycle phases above, this means that when the default lifecycle is used, Maven will first validate the project, then will try to compile the sources, run those against the tests, package the binaries (e.g. jar,wa), run integration tests against that package, verify the integration tests, install the verified package to the local repository, then deploy the installed package to a remote repository. 

Maven Phase Execution

Validate Phase

If we execute any phase in maven previous phase is automatically initiated.

Validate phase of Maven Build Lifecycle

Compile Phase

Compile phase of Maven Build Lifecycle

Test Phase

Test phase of Maven Build Lifecycle

Package phase

Package phase of Maven Build Lifecycle


Install phase

Install phase of Maven Build Lifecycle

Install phase of Maven Build Lifecycle

Summary:

1. Maven is a software build management and comprehension tool. 
2. Maven is based on the concept of a project object model, Maven helps in code build, dependency management, documentation creation, site publication, and distribution publication are all controlled from the declarative file.
3. Maven can be extended by plugins to utilize a number of other development tools for reporting or the build process.
4. Maven Archetype is a set of tools to deal with archetypes, i.e. an abstract representation of a kind of project that can be instantiated into a concrete customized Maven project. An archetype knows which files will be part of the instantiated project and which properties to fill to properly customize the project. 


Comments