且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从项目中删除未使用的 jars

更新时间:2021-07-07 10:08:50

这就是我最后做的
我使用 JBOSS TattleTale (http://www.jboss.org/tattletale) 在编译时识别未使用的 jar时间(它报告 17 罐未使用).
然后对于该列表中的每个 jar,我对我的项目进行了字符串搜索,以查找是否在任何地方使用了该 jar 的最高包级别(这是尝试查看是否加载了属于该 jar 的任何类使用反射).
通过这种方式,我成功地从我的项目中消除了 6 个 jar.
由于编译时未使用的 jar 数量很少,因此这种方法很快.

This is what I did finally
I used JBOSS TattleTale (http://www.jboss.org/tattletale) to identify unused jars at compile time (It reported 17 jars as unused).
Then for each of the jar in that list, I did a string search on my project to find if the highest package level of the jar was used anywhere (this is an attempt to see if any class belonging to this jar was loaded using reflection).
This way I was able to successfully eliminate 6 jars from my project.
Since, number of unused jars at compile time was small, this approach was quick.