ProGuard 4.2 处理SSH项目源码

假设Java安装在C:\Program Files\Java,Tomcat安装在:D:\apache-tomcat-6.0.35,要处理的SSH项目部署在D:\apache-tomcat-6.0.35\webapps\MySSHWeb。首先解压ProGuard 4.2,得到其lib目录下的proguardgui.jar、proguard.jar和retrace.jar三个文件;在同一目录下建立脚本文件start.bat,文件内容为:java -Xms512m -Xmx512m -jar proguardgui.jar。运行start.bat打开ProGuard,然后开始设置:

1:在Input/Output页进行设置:
   Add input...,输入D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\classes
   Add output...,输入D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\classes_ok
   Add...,输入D:\apache-tomcat-6.0.35\lib
   Add...,输入D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\lib

2: 在Shrinking页进行设置:
   取消Applications,选中Library
   Add...,Comments为Keep Hibernate PO,Extends/implements class为java.io.Serializable
   Add field...,点OK
   Add method...,点OK
   最后点OK

3: 在Obfuscation页进行设置:
   选中Keep attributes

4: 在Information页进行设置:
   选中Target,下拉选择1.5

5: 在Process页,点击Process!开始处理

最后可以得到处理后的classes,覆盖到D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\classes下即可。偶尔会出现个别文件有错,可以直接将对应的原文件覆盖过来。最终处理的效果不是很好,有待进一步研究。最终的配置文件如下所示:

-injars 'D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\classes_bak'
-outjars classes_bak_yes

-libraryjars 'C:\Program Files\Java\jre6\lib\rt.jar'
-libraryjars 'D:\apache-tomcat-6.0.35\lib'
-libraryjars 'D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\lib'

-target 1.5
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod


# Keep Hibernate PO
-keep class * extends java.io.Serializable {
    <fields>;
    <methods>;
}

# Keep - Library. Keep all public and protected classes, fields, and methods.
-keep public class * {
    public protected <fields>;
    public protected <methods>;
}

# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers class * extends java.lang.Enum {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# Also keep - Database drivers. Keep all implementations of java.sql.Driver.
-keep class * extends java.sql.Driver

# Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI,
# along with the special 'createUI' method.
-keep class * extends javax.swing.plaf.ComponentUI {
    public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent);
}

# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,allowshrinking class * {
    native <methods>;
}

# Remove - System method calls. Remove all invocations of System
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.System {
    public static long currentTimeMillis();
    static java.lang.Class getCallerClass();
    public static int identityHashCode(java.lang.Object);
    public static java.lang.SecurityManager getSecurityManager();
   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值