paip.批处理清理java项目冗余jar的方法
在myeclipse中开发的java项目遇到jar包冗余情况,如何删除项目中的冗余jar包啊?项目很大jar包一百多个。
2010-09-14 14:23 shuilang52 | 分类:JAVA相关 | 浏览3074次
我的意思是项目已经基本完成了,现在我要做的是把别人开发好的项目中多余的jar除去,有206个jar,其中有很多没用到的,我想问一下如何尽快的除去冗余jar 谢谢
/struct
收集import class >>deduli.
jars >>> jarKV(cls,jar),ddao include xxxxd jars...
zai 做个排除编程.... ok...
作者Attilax 艾龙, EMAIL:1466519819@qq.com
来源:attilax的专栏
地址:http://blog.csdn.net/attilax
//src\com\attilax\jar\jarX.java
public static void main(String[] args) {
iniJarKV("D:\\workspace\\lib");
String dir = "D:\\workspace\\convert2atian4telbook\\src";
List<String> files = travDir.getAllFileList(dir, "java");
for (String file : files) {
List<String> classes = IncludedClasses(file);
for (String cls : classes) {
String jar = getJar(cls);
if (jar != null)
if (!MustJar.contains(jar))
MustJar.add(jar);
}
}
// AllJar=travDir.getAllFileList(strPath, extName)
AllJar.removeAll(MustJar);
List<String> CanDelJars = AllJar;
for (String f : CanDelJars) {
File oldFile = new File(f);
// 将文件移到新文件里
File fnew = new File("c:\\CanDelJars\\" + oldFile.getName());
oldFile.renameTo(fnew);
}
String s2 = listUtil.toString_jsonFmt(CanDelJars);
System.out.println(s2);
}
static List AllJar = new ArrayList();
static Set MustJar = new HashSet();
static Map javKV = new HashMap();
[
"D:\\workspace\\convert2atian4telbook\\lib\\Java_SDK_1.2.1.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\commons-fileupload-1.2.2.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\asm-3.3.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\proxool-cglib.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\httpcore-4.1.4.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\hibernate-jpa-2.0-api-1.0.1.Final.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\aspectjrt-1.7.0.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\ognl-3.0.6.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\httpclient-4.1.3.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\commons-dbcp-1.2.1.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\commons-httpclient-3.1.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\commons-logging-1.1.1.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\hibernate-c3p0-4.1.8.Final.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\jboss-logging-3.1.0.GA.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\gson-2.2.4.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\dom4j-1.6.1.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\xstream-1.3.1.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\antlr-2.7.7.jar",
"D:\\workspace\\convert2atian4telbook\\lib\\weibo4j-oauth2.jar",
参考
显示出Jar文件中的所有目录名和文件名,也显示Manifest.mf文件所有属性 - 简单就是美! - ITeye技术网站.htm