Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixing different versions of Java libraries

My project uses Java libraries that have their own dependencies (Hadoop, Jetty for example). I end up with different versions of the same dependencies, like ant 1.4.5, 1.4.6. My project may want to use ant 1.4.7. This is a small example, can get more complicated with larger dependencies like HTTP Commons.

How do I get all the libraries and dependencies to play nice? Is there a way to isolate each library (Hadoop, Jetty) so they only use their dependencies?

like image 498
Amanibhavam Avatar asked Nov 08 '08 03:11

Amanibhavam


2 Answers

Maven will also generally handle this pretty well. If not completely, it will at least handle the bulk of it, then you can sort out the issues that are left over.

Of course that means that you have to change your build process, but it might be worth your while for not pulling your hair out over this.

like image 122
Spencer Kormos Avatar answered Sep 28 '22 03:09

Spencer Kormos


JarJar to the rescue!

An ant taks that both 1) packs many jars into one, and 2) allows you to rename dependencies in class files and thus load two versions of the same library!

like image 45
akuhn Avatar answered Sep 28 '22 03:09

akuhn