Maven is entirely based on the build lifecycle. As you know that the build lifecycle has different phases. Each phase of the lifecycle represents a stage on the build. Following are the phases of a default lifecycle:
- validate – validate the project is correct and all necessary information is available
- compile – compile the source code of the project
- test – test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
- package – take the compiled code and package it in its distributable format, such as a JAR.
- verify – run any checks on results of integration tests to ensure quality criteria are met
- install – install the package into the local repository, for use as a dependency in other projects locally
- deploy – done in the build environment, copies the final package to the remote repository for sharing with other developers and projects.
mvn clean package
mvn clean install
|This will clean the target folder||This will also clean the target folder|
|This will compile your code||This will compile your code|
|This will package your code||This will package your code|
|This will create jar if your pom says the project is a jar||This will create jar if your pom says the project is a jar|
|This will put the jar in target directory by default||This will put the jar in local repository|