SAGARFIVE

Tutorials

4.6 Maven phase

  • A Maven phase represents a stage in the Maven build lifecycle. Each phase is responsible for a specific task.
  • Here are some of the most important phases in the default build lifecycle:
  • validate: check if all information necessary for the build is available
  • compile: compile the source code
  • test-compile: compile the test source code
  • test: run unit tests
  • package: package compiled source code into the distributable format (jar, war, …)
  • integration-test: process and deploy the package if needed to run integration tests
  • install: install the package to a local repository
  • deploy: copy the package to the remote repository
  • For the full list of each lifecycle’s phases, check out the Maven Reference.
  • Maven phase command

mvn <PHASE>
  • Phases are executed in a specific order. This means that if we run a specific phase using the command:
  • It won’t only execute the specified phase, but all the preceding phases as well.
  • For example, if we run the deploy phase, which is the last phase in the default build lifecycle, it’ll execute all the phases before the deploy phase as well, which is the entire default lifecycle:

mvn deploy