Maven organizes build steps into three independent, built-in lifecycles: clean, default (the main build lifecycle), and site. Each lifecycle is made up of an ordered set of phases, and each phase can have plugin goals bound to it.
Key Points: • The clean lifecycle has phases pre-clean, clean, and post-clean, and removes previously generated build files. • The default lifecycle is the main one used for building and deploying, with key phases including compile, test, package, verify, install, and deploy. • The site lifecycle generates project documentation and reports, with phases like pre-site, site, post-site, and site-deploy. • The three lifecycles are independent of each other — running mvn clean does not run any default-lifecycle phases unless explicitly chained. • Within a lifecycle, invoking a later phase always triggers all earlier phases first.
Example: Running mvn clean deploy executes the entire clean lifecycle first, then runs through the default lifecycle up to and including deploy, publishing the artifact to a remote repository.
Interview Tip: A concise interview answer is:
"Maven has three built-in lifecycles — clean, default, and site — each with its own ordered phases. The default lifecycle is the one most people mean when they say 'Maven build,' covering compile through deploy, while clean removes old output and site builds documentation."