Remove unused methods/classes from dependencies

Florian :

Many libraries contain much more functions than I need. If I shade them into my jar, the jar contains 80% code which is never used.

Is there a way to remove any unused methods & classes from the dependencies I shade into my jar?

GhostCat salutes Monica C. :

Unless you have extremely good integration tests I advise to be really careful about this idea.

Far too often frameworks might use reflection here or there - and no tool can determine through static analysis which parts of the code will be called via reflection.

Beyond that: how many megabytes are we talking here? Keep in mind that a Java SE installation contains many thousand classes which you will never be using.

What I mean: is this a real problem or a assumed one? Did a customer complain about too many dependencies? Is there anything that causes real trouble for you? Then, and only then you should be looking into reducing the "jar content".

Finally: keep in mind that you are the one who created those dependencies in the first place! So, when you are worried about the number of items pulled in for your product - maybe you first check if there are ways to reduce the direct dependencies of your product. Instead of going with a "too large" list and that idea to reduce jar contents as suggested in the question.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=463166&siteId=1