Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven install and deploy

Tags:

maven-2

I have some doubt regarding our setup in our ci server. The maven command used to build applications is configured in bamboo as "mvn install deploy".

As of my understanding this would invoke all phases up to "install" and then invoke all phases again up to "deploy", which would mean and as I can see in our logs, that the applications are build twice (twice compile, twice test) etc.. Which also means that the applications takes almost twice as long to build as needed.

All that's needed is "mvn deploy" to correctly build the applications.

Is my understanding/observation correct?

like image 979
Fredrik Avatar asked Aug 04 '10 12:08

Fredrik


People also ask

What is Maven install and Maven deploy?

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.

Does Maven deploy also install?

So, the answer is yes, mvn deploy will execute install and build the project artifacts.

What is deploy in Maven?

deploy:deploy is used to automatically install the artifact, its pom and the attached artifacts produced by a particular project. Most if not all of the information related to the deployment is stored in the project's pom. deploy:deploy-file is used to install a single artifact along with its pom.

What is the difference between Maven package and install?

mvn package command will compile source code and also package it as a jar or war as per pom file and put it into the target folder(by default). mvn install command will compile and package, but it will also put the package in your local repository.


1 Answers

Yes all you have to do is look at the execution life cycle.

  • validate - validate the project is correct and all necessary information is available
  • compile - compile the source code of the project
  • test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
  • package - take the compiled code and package it in its distributable format, such as a JAR.
  • integration-test - process and deploy the package if necessary into an environment where integration tests can be run
  • verify - run any checks to verify the package is valid and meets quality criteria
  • 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.

Here you can see that install happens right before deploy. What is important to know that when you run deploy, maven will run all other phases and then said goal. So running install then deploy will run up to install twice then a single deploy.

like image 146
John Vint Avatar answered Sep 28 '22 08:09

John Vint