This is an short tutorial on Difference between
install command in maven.
You can check my other posts on maven commands.
install are the goal phases of maven life cycle.
Before that first understand the maven life cycle goals on the order execution.
maven default life cycle goals execution order
validate: validate checks all the valid information of an maven application
compile: Compile source code into class files i.e java to class files which also includes test classes (java and test folder java files)
test: Running test classes located in src/main/test folder
package: package the output of compiled source code and output is JAR,WAR,EAR files.
verify: Checks integration test and verify the result
install: This installs the jar/war file into local repository, so that other projects can use these as an dependency.
deploy: This deploy artifact jar/war into remote repository.
Maven clean life cycle
pre-clean: execute the validation before clean goal
clean: delete the previous build files located in
post-clean: execute the validation tasks after clean goal
difference between mvn clean install and mvn clean package?
clean goal in both commands cleans and removes previous build files, It removes target folder of an maven project.
mvn clean package goal: This goal packages the project and output jar/war/ear file based on pom module.
if your pom.xml contains package=jar, It creates jar package if it is war package, it generates war package.
goal runs the below goals execution order
validate -> compile -> test -> package
maven clean install goal installs the artifact to local repository, so that other projects or applications can make this as an dependency and use in their projects.
Here is an order of execution
validate -> compile -> test -> package -> verify - install
install goals execution comes after package goal