Repaso
EspaƱol

Which is the correct order of the main Maven default lifecycle phases?

Options

  1. package, compile, test, install, verify, deploy
  2. validate, compile, test, package, verify, install (Correct option)
  3. compile, deploy, test, package, install, validate
  4. test, compile, install, clean, package, validate

Answer

validate, compile, test, package, verify, install, deploy

Why

Maven's default lifecycle runs phases in order, and running a phase also runs all previous ones:

  1. validate: check the project is correct.
  2. compile: compile src/main/java.
  3. test: run unit tests.
  4. package: create the JAR/WAR.
  5. verify: run integration checks.
  6. install: copy the artifact to your local repository (~/.m2).
  7. deploy: upload it to a remote repository.

clean belongs to a separate lifecycle: it deletes target/.

Remember

validate, compile, test, package, verify, install, deploy.

Key terms

Practice this question in Repaso