5 Answers. Show activity on this post. clean is its own build lifecycle phase (which can be thought of as an action or task) in Maven. mvn clean install tells Maven to do the clean phase in each module before running the install phase for each module.
mvn package command will compile source code and also package it as a jar or war as per pom file and put it into the target folder(by default). mvn install command will compile and package, but it will also put the package in your local repository.
mvn test-compile: Compiles the test source code. mvn test: Runs tests for the project. mvn package: Creates JAR or WAR file for the project to convert it into a distributable format. mvn install: Deploys the packaged JAR/ WAR file to the local repository.
As you might be aware of, Maven is a build automation tool provided by Apache which does more than dependency management. We can make it as a peer of Ant and Makefile which downloads all of the dependencies required.
On a mvn install
, it frames a dependency tree based on the project configuration pom.xml
on all the sub projects under the super pom.xml
(the root POM) and downloads/compiles all the needed components in a directory called .m2
under the user's folder. These dependencies will have to be resolved for the project to be built without any errors, and mvn install
is one utility that could download most of the dependencies.
Further, there are other utils within Maven like dependency:resolve
which can be used separately in any specific cases. The build life cycle of the mvn is as below: LifeCycle Bindings
process-resources
compile
process-test-resources
test-compile
test
package
install
deploy
The test phase of this mvn can be ignored by using a flag -DskipTests=true
.
Have you looked at any of the Maven docs, for example, the maven install plugin docs?
Nutshell version: it will build the project and install it in your local repository.
The install:install
goal is provided by «Apache Maven Install Plugin»:
Apache Maven Install Plugin
The Install Plugin is used during the install phase to add artifact(s) to the local repository. The Install Plugin uses the information in the POM (
groupId
,artifactId
,version
) to determine the proper location for the artifact within the local repository.The local repository is the local cache where all artifacts needed for the build are stored. By default, it is located within the user's home directory (
~/.m2/repository
) but the location can be configured in~/.m2/settings.xml
using the<localRepository>
element.— Apache Maven Install Plugin - Introduction.
Having said that, the exact goal purpose:
install:install
is used to automatically install the project's main artifact (the JAR, WAR or EAR), its POM and any attached artifacts (sources, javadoc, etc) produced by a particular project.— Apache Maven Install Plugin - Introduction.
For additional details on the goal, please refer to the Apache Maven Install Plugin - install:install page.
For additional details on the build lifecycle in general and on which place the goal has in the build lifecycle, please refer to the Maven – Introduction to the Build Lifecycle page.
It will run all goals of all configured plugins associated with any phase of the default lifecycle up to the "install" phase:
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
Short answer
mvn install
- adds all artifact (dependencies) specified in pom, to the local repository (from remote sources).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With