3 ms·
I’m not a java developer and don’t know maven deep but once I’ve tried to perform a simple task and abandoned it after a couple hours of googling and experimen
by citrin_ru 3y ago
I’m not a java developer and don’t know maven deep but once I’ve tried to perform a simple task and abandoned it after a couple hours of googling and experimenting: 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. In Go it is as easy as running goimports and go mod tidy and one doesn’t have to be a Go expert to use them.
- 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.