17

I think there should be some difference, but can anyone tell me the details?

xlm
  • 6,854
  • 14
  • 53
  • 55
user705414
  • 20,472
  • 39
  • 112
  • 155
  • [this](http://stackoverflow.com/questions/207281/what-is-the-difference-between-mvn-deploy-to-a-local-repo-and-mvn-install) may be what you are looking for. – kdabir Sep 23 '11 at 15:08

4 Answers4

39

mvn:install copies your packaged Maven module to your local repository (by default, in ~/.m2/repository), to be accessed by other local Maven builds.

mvn:deploy uploads your packaged Maven module to another (usually remote) repository, to be accessed by other, not necessarily local, Maven builds.

See the documentation for the build lifecycle for more info.

Daniel
  • 10,115
  • 3
  • 44
  • 62
3

The install phase is responsible for the installation of artifacts into local caching repositories. This basically applies to the Maven repository, but a well-known example is also the OSGi Bundle Repository supported by maven-bundle-plugin.

The deploy phase is responsible for the installation of artifacts into published repositories. This usually applies to remote repositories, but is could perfectly be a local repository exposed to the outside world.

As all Maven phases, you can do with them anything you want. You can shuffle plugin phases as you see fit, but the above semantics is the conventional one and you should stick to it in order to be consistent with the default phases of other plugins' goals.

Luca Geretti
  • 10,206
  • 7
  • 48
  • 58
2

mvn:deploy performs deployment to remote reposiory/environment, mvn:install installs all compiled packages to a local repository making them available to other builds performed on the local machine.

Andrey Adamovich
  • 20,285
  • 14
  • 94
  • 132
1

In one sentence: mvn:install compiles and installs your component in your local Maven repository, so that you can use it when other components used and developed locally depend on it. mvn:deploy deploys your (previously installed) component to a remote repository.

mliebelt
  • 15,345
  • 7
  • 55
  • 92
  • Does the module _really_ need to be installed before deploying? – Daniel Sep 23 '11 at 15:18
  • I think the default life cycle of Maven contains that. And if you do only deploy it, what should be deployed then? See the documentation at http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html. there is stated: That is because if you call a build phase, it will execute not only that build phase, but also every build phase prior to the called build phase. – mliebelt Sep 23 '11 at 15:21
  • 1
    That's 2 sentences! – David Newcomb Nov 21 '16 at 09:53