I don't really get this mvn deploy
and why do we do it?
I do
mvn clean install
Then i do
mvn jetty:run
I am just bit confused on why do we need to do this or should i 开发者_Go百科do deployment once in a while.
Simply put Maven resolves artifacts (the ones you put in the dependencies section) from a local repository (typically $HOME/.m2/repository). If it cannot find the artifact in the local repository it will look i a remote repository. The standard remote repository is the "central" repositrory at http://repo1.maven.org/maven2. If you execute "mvn install" you tell Maven to copy your artifacts (your WAR in the target folder) to the local repository. Now your other Maven projects can resolve the artifact. If you want others to be able to resolve the artifact you need to put it on a remote repository. This is done with "mvn deploy" (just like the central repository, you can create your own remote repository).
In order to deploy your web application you need to either manually deploy the WAR file from the target folder or use a Maven plugin like Cargo to deploy to the application server.
What is the point of deploying WAR files to a remote Maven repository, when they usually are not used as dependency in other projects?
I would suggest that prior to deploying something on the application server you do a proper release of your code. There is a release plugin that helps you with that. In addition to putting it on the remote Maven repository it tags the current source in your SCM (e.g. subversion). Now you have a versioned binary in your Maven repository that matches a tagged version in your SCM. Since the Maven repository has a well-defined structure it is easy to write scripts that pull a new version to the production server.
Maven Deploy Plugin Excerpt:
The deploy plugin is primarily used during the deploy phase, to add your artifact(s) to a remote repository for sharing with other developers and projects. This is usually done in an integration or release environment. It can also be used to deploy a particular artifact (e.g. a third party jar like Sun's non redistributable reference implementations).
versus
Maven Install Plugin Excerpt
The Install Plugin is used during the install phase to add artifact(s) to the local repository
精彩评论