mvn install: Publish to the Local Repository
mvn install runs the full lifecycle through verify and then installs the built artifact (and pom) into the local ~/.m2 repository for other local builds to resolve.
install is how one module makes itself available to another on the same machine. In CI it matters mainly for multi-module reactor builds and caching.
What it does
Invoking install runs validate through verify, then the install phase copies the artifact and its pom into ~/.m2/repository under its coordinates. Other projects on the same machine can then resolve it without a remote repository. It does not push anywhere remote.
Common usage
mvn install
mvn clean install -DskipTests
mvn install -pl module-a -am # install module-a and its depsFlags
| Flag | What it does |
|---|---|
| -pl <modules> | Build only the listed reactor modules |
| -am | Also build modules they depend on |
| -DskipTests | Skip running tests |
| -o | Offline mode |
| -B | Batch mode for CI |
In CI
For a multi-module repo, mvn -B install builds the whole reactor and resolves inter-module deps from the freshly installed artifacts. Cache ~/.m2/repository, but be aware it now holds your own SNAPSHOTs; a stale local SNAPSHOT can mask a build issue, so clean install when in doubt.
Common errors in CI
"Could not find artifact com.acme:module-b:jar in ..." in a partial build means a sibling module was not installed; add -am or build the full reactor. "Failed to execute goal ... maven-install-plugin" with a permission error means ~/.m2 is read-only on the runner. Test/compile failures here are the same as in earlier phases.