2 ms·
> I’ve tried to remove from pom.xml dependencies which are listed there but not used in the source code and it was surprisingly hard to do. You probably alread
by cesarb 3y ago
> I’ve tried to remove from pom.xml dependencies which are listed there but not used in the source code and it was surprisingly hard to do.
You probably already know this, but since Java has dynamic loading of code, even if the dependency is not used in the source code, it does not mean the dependency will not be used when running the code. Either through direct use of reflection ("Class.forName()"), or a drop-in file used through ServiceLoader, or even a magic resource file which makes the code go through a different path when present. Carelessly removing a dependency might make your application break, possibly only when the specific functionality which dynamically needs the removed dependency is called. So yeah, you kind of have to be an expert on all the frameworks your application uses before you can start trying to remove unused dependencies in Java, and a tool cannot help you much.