简体   繁体   中英

Can Maven pull the dependency into the project?

I am working on a number of small projects with Eclipse, Spring, Java and Tomcat using Subversion for version control. I am looking to try to use Maven for the first time but one thing I see already that I don't like is that if I start a project with maven it will download all the dependency into my .m2 folder and all the class path to the projects but we like to have all the dependency moved into WEB-INF/lib so we can check them into Subversion.

Can this be done with Maven? Should it be done this way?

Checking in binary packages into your source control isn't really ideal, and goes against the grain with maven. A valid concern is what happens when those online repositories go down and the solution is to host your own repository using something like Artifactory . Some people don't like that they have to maintain another system along side with the source control, but it's worth it to get all the features that maven brings to the table.

You can download dependencies with aid of Maven (eg by using the maven-dependeny-plugin ), but most certainly you do not want to do that.

From Why not Store JARs in CVS? (or any other version control system):

  • It uses less storage - while a repository is typically quite large, because each JAR is only kept in the one place it is actually saving space, even though it may not seem that way
  • It makes checking out a project quicker - initial checkout, and to a small degree updating, a project will be faster if there are no large binary files in CVS. While they may need to be downloaded again afterwards anyway, this only happens once and may not be necessary for some common JARs already in place.
  • No need for versioning - CVS and other source control systems are designed for versioning files, but external dependencies typically don't change, or if they do their filename changes anyway to indicate the new version. Storing these in CVS doesn't have any added benefit over keeping them in a local artifact cache.

The most important thing to understand about Maven is that dependencies of a project should not be checked in into version control (does not depend on which version control). The idea of Maven is to have the dependencies only in a single place $HOME/.m2/repository. This means for every project you are working you have only the dependencies an single time on your hard drive. The dependency management makes it easy to add/change/remove dependencies from your project. Furthermore Maven will not only handle dependencies it will support you in doing unit/integration testing , creation of reporting like code-coverage etc. and much more. If you really thinking of working with Maven you should set up a Repository Manager like Nexus, Artifactory or Archiva.

The most important point is if you don't like the way Maven works that get the your fingers off from Maven otherwise you will loose the challenge. If you like to work with maven you have to accept the Maven Way .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM