Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding out all conflicting packages/classes of referenced jars in an Eclipse project

I am currently dealing with a huge Eclipse project (not written by me). This project doesn't use any dependency management tools. It references hundreds of JARs.

Some of these JARs contain same packages (and classes), but in different versions. Currently, resolving conflicts works by manually (and randomly!) reordering these JARs in Order&Export (in Project Properties).

This was done for a long time now, and there are now lots of packages/classes with different vendors/versions/product-lines.

Reordering causes some parts of the project to fail while other parts start working, and oppositely. Strangely, lots of orders do not cause build errors, but only runtime errors.

Can this mess be solved by an tool, which would suggest certain automatic order of dependent JARs?

like image 492
java.is.for.desktop.indeed Avatar asked Jul 25 '11 13:07

java.is.for.desktop.indeed


1 Answers

Google for JarAnalyzer, that helps at least to figure how the dependecies are build up. Use the jars, your eclipse project is producing, as well. However you can not really automate this. Imagine one of your eclipse projects in needing bad-1.0.jar and another one uses bad-1.2.jar. Very often you can not replace the 1.0 one with the 1.2 one because your project wont compile any more. So in the long run you have to REMOVE outdated jars, switch to a "common version" amoung all subprojects and fix the compiler errors. And while you do that, switch to ivy or maven.

Do your jar files even have proper names or do you have 3 different versions of bad.jar which look the same in the filesystem but are in fact of different version? If so, start by renaming all relevant jar files to include the version number (can often eb found in the manifest file) ... heck I once did what you do and wrote me with JArAnalyzer, a bit groovy and some shell scripts a small tool that generated all the ivy files for the project.

like image 192
Angel O'Sphere Avatar answered Oct 05 '22 12:10

Angel O'Sphere