What are the advantages of using Maven's public repository vs storing your libraries locally?
I see the following disadvantages in using public repository:
In order to avoid using a public repo I'm following this advice, someone however also suggested
"run something like Nexus, your own maven repo that you can upload 3rd party proprietary jar files, and also proxy other public repositories, to save on bandwith?".
That really summarizes my doubts: why go through all that pain for simply sharing library files to a couple of developers?
- If for some reason some library is updated my application will probably crash, considering I use hundreds of libraries that's bound to happen sometime.
No. I know Murphy's law states that anything that can happen will happen. But libraries published in Maven Central are supposed to be stable. If a library is updated, it will be with a new version so there are no conflicts. No sane maintainer of a library would go against that.
- If a specific library version is specified to avoid newer versions to break the application, that specific version might not be available anymore.
No. You can't remove an artifact from Maven Central. So this is not possible.
- The repositories might always be subject to network problems or similar error blocking development of the software completely, a local lib folder with all the required jars shared through git is more robust.
While that is true, Maven keeps a cache of all artifacts inside your local repository. It just needs to download them once.
The advantage of using an internal repository manager goes beyond the scope of caching Maven Central. It allows a central entry point for all dependencies, whether or not those dependencies are public. It can also host internal library and private libraries (like Oracle JDBC). Also, using it is transparent for Maven projects: dependencies are declared exactly the same way, whether it is a public artifact or a in-house one.
Just one important advantage of using central repository: You do not need to add all transitive dependencies manually. Usually this list can be huge and you'll be able to notice it only by running you application while auto-dependency management will update classpath with all required libs.