Detecting all conflicting reference jar packages / classes in an Eclipse project

I am currently dealing with a huge Eclipse project (not written by me). This project does not use any dependency management tools. It refers to hundreds of JARs.

Some of these JARs contain the same packages (and classes), but in different versions. Currently, conflict resolution works manually (and randomly!), Reordering these JARs in Order&Export (in project properties).

This has been done for a long time, and now there are many packages / classes with different suppliers / versions / product lines.

Reordering causes some parts of the project to fail when other parts start working, and vice versa. Oddly enough, many orders do not cause build errors, but only runtime errors.

Could this mess be resolved by a tool that involves some automatic ordering of dependent JARs?

+6
source share
3 answers

Google for JarAnalyzer, which helps to at least understand how dependencies are created. Use banks, your eclipse project also produces. However, you cannot automate this. Imagine one of your eclipse projects needs bad-1.0.jar and the other uses bad-1.2.jar. Very often, you cannot replace 1.0 with 1.2, because your project will no longer compile. Therefore, in the end, you need to DELETE obsolete banks, switch to the "general version" for all subprojects and fix the compiler errors. And while you do this, switch to ivy or maven.

Do your jar files even have their own names or do you have 3 different versions of bad.jar that look the same on the file system but actually have a different version? If so, start by renaming all the relevant jar files to include the version number (you can often find eb in the manifest file) ... heck I somehow did what you did and wrote me with JArAnalyzer, a bit groovy and some scripts The shell is a small tool that generated all the ivy files for the project.

+1
source

you can use maven, ivy to clear the mess :). And that spring does not work correctly, try this: clean up first, then build the project.

0
source

"Oddly enough, many orders do not cause assembly errors, but only the runtime of the error."

This is not strange. As you wrote, classes are present in different versions, which does not necessarily mean a compilation error, but means different behavior and different sub dependencies.

Avoid "random" or "automatic ordering." I would advise you to use Maven to handle your dependencies (to know exactly which library depends on which). You will probably find that many of the libraries that you include are not required, and that the dependency management tool will automatically handle all dependencies between dependencies for you, you should, however, add / force an exception for specific versions of the libraries.

Significantly more, this will help you simplify the code and, in the end, remove one line of code and 40 dependencies ... (relying on a third-party structure using such Spring or any other).

0
source

Source: https://habr.com/ru/post/893497/


All Articles