从项目中删除未使用的 jars [英] remove unused jars from project

查看:32
本文介绍了从项目中删除未使用的 jars的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


从我的 java (ant) 项目中删除未使用的 jar 的最简单方法(工具?)是什么.我们的项目变得非常庞大,我们想要进行清理.有几个 jars 被添加到类路径中,但并不是所有的 jars 都用于编译/运行.有没有办法通过从命令行运行一些实用程序来识别不必要的 jars?
注意:我们不想遵循删除一个或多个 jar 的繁琐过程,然后编译/运行以测试它们是否需要.


What is the easiest way (tool ?) to remove unused jars from my java (ant ) project. Our project has become really huge, and we want to do a clean up. There are several jars that are added to the classpath, but not all are used for compile/run. Is there a way to identify the unnecessary jars by running some utility from command line?
Note: we do not want to follow the tedious process of removing one or more jars, then compile/run to test if those are required or not.

推荐答案

这就是我最后做的
我使用 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.

这篇关于从项目中删除未使用的 jars的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆