What does mvn install in maven exactly do

java, maven, pom.xml

Solution

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`.

Problem

I just started using Maven and I was told to do `mvn install` in a specific directory. What does `mvn install` do, exactly? I think it looks for `pom.xml` in the current folder and starts following the instructions specified in that file. Is that correct?

Original source