Wednesday, 10 July 2019

Maven build lifecycle


Build life cycle defines the process of build and deploying the artifact. Maven defines 3 built-in lifecycles.
         a. default: It handles the project deployment
         b. clean: Handles project cleaning. Delete the build artifacts.
         c. site: Handles the project's documentation, used to build a website for your project.
        
Every build life cycle is made by set of build phases. Each phase represents a stage in the lifecycle and bound to one or more maven plugin goals.

For example, default build cycle has below phases.

a.   Validate
b.   Initialize
c.    generate-sources
d.   process-sources
e.   generate-resources
f.     process-resources
g.   compile
h.   process-classes
i.     generate-test-sources
j.     process-test-sources
k.    generate-test-resources
l.     process-test-resources
m. test-compile
n.   process-test-classes
o.   test
p.   prepare-package
q.   package
r.     pre-integration-test
s.    integration-test
t.     post-integration-test
u.   verify
v.    install
w.  deploy.




How to execute a phase?
Syntax
 mvn <PHASE_TO_EXECUTE>
Above command execute all the preceding phases and this phase as well.

Example
mvn compile
 
Above command execute all the phases before compile, and the compile phase as well.
 
Clean build cycle clean has below phases.
a.   pre-clean
b.   clean
c.    post-clean

site build life cycle has below phases.
a.   pre-site
b.   site
c.    post-site
d.   site-deploy

In my next posts, I will explain these build cycles in detail.

Reference



Previous                                                    Next                                                    Home

No comments:

Post a Comment