What is the difference between “mvn deploy” to a local repo and “mvn install”?

前端 未结 3 518
無奈伤痛
無奈伤痛 2020-11-30 19:06

My team uses an internal team maven repo that is shared from a development server using Apache. We also run the Continuum CI server on the same machine. Maven builds in Cont

相关标签:
3条回答
  • 2020-11-30 19:31

    "matt b" has it right, but to be specific, the "install" goal copies your built target to the local repository on your file system; useful for small changes across projects not currently meant for the full group.

    The "deploy" goal uploads it to your shared repository for when your work is finished, and then can be shared by other people who require it for their project.

    In your case, it seems that "install" is used to make the management of the deployment easier since CI's local repo is the shared repo. If CI was on another box, it would have to use the "deploy" goal.

    0 讨论(0)
  • 2020-11-30 19:39

    Ken, good question. I should be more explicit in the The Definitive Guide about the difference. "install" and "deploy" serve two different purposes in a build. "install" refers to the process of installing an artifact in your local repository. "deploy" refers to the process of deploying an artifact to a remote repository.

    Example:

    1. When I run a large multi-module project on a my machine, I'm going to usually run "mvn install". This is going to install all of the generated binary software artifacts (usually JARs) in my local repository. Then when I build individual modules in the build, Maven is going to retrieve the dependencies from the local repository.

    2. When it comes time to deploy snapshots or releases, I'm going to run "mvn deploy". Running this is going to attempt to deploy the files to a remote repository or server. Usually I'm going to be deploying to a repository manager such as Nexus

    It is true that running "deploy" is going to require some extra configuration, you are going to have to supply a distributionManagement section in your POM.

    0 讨论(0)
  • 2020-11-30 19:44

    From the Maven docs, sounds like it's just a difference in which repository you install the package into:

    • install - install the package into the local repository, for use as a dependency in other projects locally
    • deploy - done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

    Maybe there is some confusion in that "install" to the CI server installs it to it's local repository, which then you as a user are sharing?

    0 讨论(0)
提交回复
热议问题