Maven Build Phases with Example

Maven Build Phases with Example:
As we have already discussed some of the most commonly and frequently used Maven build phases (Here). Now let us see an example of executing Maven Build Phases in a java project.

We are going to see how to execute,

  • Validate: Validates the project and checks all the necessary informations are available
  • Compile: Compiles the source code
  • Test: Tests the source code using suitable unit testing framework
  • Package: Compiled code is packaged in a distributable format (ex: jar)
  • Install: Installs the package in local repository
  • Deploy: Copies the package to remote repository

Project Structure:

Now let us run the phases in command prompt, Open the command prompt

mvn clean validate

mvn clean compile:

mvn clean install:

mvn clean package:

If we have test cases, we can run mvn clean test and mvn clean deploy will install it in remote repository


Leave a Reply

Your email address will not be published. Required fields are marked *