tags:

views:

8357

answers:

4

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 Continuum are run with the "install" goal, which copies the final artifact directly into the shared directory.

The question is, what is the difference between adding files to the shared repo using mvn install and using the deploy goal (mvn-deploy plugin)?

It seems to me that using mvn deploy creates additional configuration hassles, but I have read somewhere that installing files into a shared repo is a bad idea for some reason related to the internal workings of maven.

update: I get the functional differences between deploy and install; I am actually more interested in the low level details in terms of what files are created in the maven repo.

+3  A: 

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?

matt b
+2  A: 

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

Spencer K
+10  A: 

Ken, good question. I should be more explicit in the The Definitive Guide about the difference. "install" and "deploy" serve two difference 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 form 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.

tobrien
Wow, one of the best explanations I've seen this week :-)
lisak
+2  A: 

But if I run mvn deploy does it build new artifacts or it just deploy the already existing artifacts in to the remote server.When we are doing a release we just build in our local machine and do the QA and then we host it in to repository. if we run mvn deploy does it create new artifacts, this cause having different artifact in the repository and in binary distribution because we are creating the binary distro from our local repo. but if someone get the source code and do the build they'll get a different one. But if mvn deploy doesn't build but only deploy it's fine.

Lahiru Gunathilake
Please post this as a new question.
Pascal Thivent
I wanted to upvote the new question, but upvoted here so rep would be properly given to the owner.
Adam
No problem, I didn't move the question for rep farming.
Pascal Thivent
@Lahiru I answered your question here: http://stackoverflow.com/questions/1544619/if-i-run-mvn-deploy-does-it-build-new-artifacts-or-it-just-deploy-the-already-exi
Pascal Thivent