8

Which are the main advantages of Maven dependencies management? We have a versioned lib folder on the server and each developer just needs to import that directory in the IDE and keep it up to date. Could Maven be simpler than that?

Beryllium
  • 12,808
  • 10
  • 56
  • 86
argon argon
  • 159
  • 1
  • 1
  • 8

6 Answers6

12

Using a per-project lib seems like a simple solution and it is. But eventually you will run into problems:

  • How do you remember where you got foo.jar from?
  • Are you sure it was a legit source that no hacker tampered with?
  • Which version is foo.jar exactly? Is it the original version or something that you patched?
  • You want JavaDoc/sources with that?
  • foo.jar needs a.jar which needs y.jar which needs z.jar needs ... You really want to download all that and manage it individually?
  • You start a second project. Now you have two lib folders. Do you copy the jars or do you reference them from the first project?
  • Your second project needs a different version of one JAR. How do you handle this?
  • Imagine you want to upgrade foo.jar to the next version. With Maven, this is a one-minute task. With a lib folder, it means: Searching the web, downloading the JAR, putting it in the right place, possible renaming it, deleting the old version, adding the new version, committing the change, cursing, doing the same for all dependencies, ...
  • You want to share your project with someone else. They might not want your versions of the JARs - Maven has a simple and efficient mechanism to override dependencies.
  • Eventually, your legal department will come to ask you to guarantee that your project is clean of incompatible licenses. Maven can give you a report of all licenses of all your dependencies.
Community
  • 1
  • 1
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
2

With maven you can have a private repository, or use public ones (like maven2) to obtain the libraries you use in your project, so you don't have to download them personally and manage them between your coworkers with your subversion server.

If you want to change one library for another one, or update it to a newer version you only have to modify the version number or the library name in your maven configuration file and it will be done, without care about where can you download the library from, and without having to share it with everyone. You will only have to share your pom.xml file.

Maven doesn't only give you this, you can configurate how to package the application (WAR, EAR, JAR, APK, etc.), compile it (JDK version, parameters, etc.) and even how to create the Eclipse structure of your project, so you can create a new project having only your sources, resources and the magic "pom.xml" maven configuration file.

You should give it a try!

maqjav
  • 2,310
  • 3
  • 23
  • 35
1

Yes it can!

"each developer just need to import that dir in the ide and keep it up to date"

Maven does this automagically ;-)

Also it has big advantages if you use continous integration and other deployment mechanisms. You can easilly build your project in any environment without caring about some lib folders. Additially there are a lot of plugins regarding building, deployment, code analasys and many more.

André Stannek
  • 7,773
  • 31
  • 52
1

Of course Maven is great, but there are also times when a versioned lib folder like yours can at least appear to be simpler. When you use libraries that don't have maven metadata, then you need to do some work before you can put it in your Maven Repo (you probably should still have one central repo on some server where you put such things).

kutschkem
  • 7,826
  • 3
  • 21
  • 56
0

Following advantage you will get by using Maven dependencies:


1. Coherence: - Maven allows organizations to standardize on a set of best practices. Because Maven projects adhere to a standard model they are less opaque. The definition of this term from the American Heritage dictionary captures the meaning perfectly: "Marked by an orderly, logical, and aesthetically consistent relation of parts."

2. Reusability: - Maven is built upon a foundation of reuse. When you adopt Maven you are effectively reusing the best practices of an entire industry.

3. Agility: - Maven lowers the barrier to reuse not only of build logic but of components. When using Maven it is easier to create a component and integrate it into a multi-project build. It is easier for developers to jump between different projects without a steep learning curve that accompanies a custom, home-grown build system.

3. Maintainability: - Organizations that adopt Maven can stop building the build, and start focusing on the application. Maven projects are more maintainable because they have fewer surprises and follow a common model.

Click here to know about more benefit

Masudul
  • 21,823
  • 5
  • 43
  • 58
0

Addtional benefits of the dependency management of Maven:

  • it's easy to get the Javadoc for most libraries
  • it's easy to get the source code for most libraries (e.g. useful if you want to debug something)
  • it's easy to specify and analyze what jar needs at what dependencies at compile-, run-, test-time.
Puce
  • 37,247
  • 13
  • 80
  • 152