Maven A concept of Build Lifecycle

Posted By : Sakshi Dewan Gandhi | 31-Dec-2017

BUILD LIFECYCLE

Maven is basically a concept of Build Lifecycle. This means that the building and distributing an artifact is defined clearly. For a person who is building a project, it is necessary for him to learn a small set of commands in order to build any maven project and with the help of a file named: POM they can get the results they desire to achieve. And, there are three main types of build lifecycles which are build-in these are:

A.Default.

B.Clean.

C.Site.

Default Lifecycle: This life cycle as the name suggests, is all about handling the project deployment.

Clean Lifecycle: This life cycle will be responsible for cleaning the project.

Site: This lifecycle is held responsible for our project’s site documentation.

 

Build Lifecycle is made up of many Phases, these are: A build-phase represents a stage in any lifecycle. And, Build Lifecycles are defined by different build phases lists. A default lifecycle will contain following phases, which are used in the order as specified only:

 

CLEAN LIFECYCLE:

pre-clean

This will execute the processes, even prior to the project cleaning.

clean

This removes all the files generated by the previous build.

post-clean

This will execute the processes left in the clean which are required to remove the files.

 

DEFAULT LIFECYCLE:

 

validate

all the necessary information is available, and validate the project is correct.

initialize

initalising build state: eg set properties.

generate-sources

generate any source code for inclusion in the compilation.

process-sources

to filter any values,processing the source code.

generate-resources

generating resource to include in the package.

process-resources

destination directory which is ready for packaging is used for copying and processing the resources.

compile

This is to compile the source code of java project.

process-classes

These are the files after the process happens .Example to do bytecode enhancement on java classes.

generate-test-sources

This is to generate any test source code to be included while compilation.

process-test-sources

This is to process the testing code. Example to filter any code value.

generate-test-resources

This is to create resources for testing purpose.

process-test-resources

This is to process the resources after copying them into the test destination directories.

test-compile

This is to compile the testing source code into the test destination directory.

process-test-classes

There are generated files from the test compilation which are post-processed here. Example doing bytecode enhancement on java classes.

test

This is to run the test by using a suitable unit-testing framework. These tests might not require the code be packaged or deployed.

prepare-package

This will perform any operations necessary to be done before actual packaging to prepare for packaging.

package

This will form the projects after their compilation in their distributable formats such as JARs.

pre-integration-test

This might include setting up the right environment, which is an action before the integration tests are executed.

Integration-test

Processing and deploying the projects into such environments where the integration testing on them can be done.

post-integration-test

This might include process of cleaning up the package as well, as it requires actions after the integration test executions have been completed.

verify

This runs the quality checks to validate and see if it meets the quality criteria.

install

This will install the package into the local repository, to be used by other projects as dependencies locally only.

deploy

This will copy the final package to the remote repository, for sharing it with other developers etc. this is basically done in release environment.

 

 

SITE LIFECYCLE:

 

 

pre-site

Before the actual project site generation, there is a need for executing certain processes, pre-site does that.

site

This executes the actual project site documentation.

post-site

This will execute the project site documentation processes, which will be executed to finalize the site generation.

site-deploy

This will be required to actually deployed the site documentation to the web server specified.

 

 

According to the above life cycle, when we use default life cycle., it will first be validated by maven, then it will complete the resources,these are run against the tests, jars are packaged,integration is done and verified, installing it to the local repository, then finally deploying it to a remote repository.

 
Related Tags

About Author

Author Image
Sakshi Dewan Gandhi

Sakshi has experience into Testing, which comprises of Functional, Performance and End-to end-System Testing. She has worked in various domains like: Telecom, E-Commerce, E-Learning and Language Translation.

Request for Proposal

Name is required

Comment is required

Sending message..