这是一个IDEA的maven项目。

我把项目名target项目名-1.0-small.war文件解压缩后,WEB-INFclasses包名下除了xml文件,都是空的。

build信息:

[proguard] Note: there were 84 unkept descriptor classes in kept class members.

[proguard] You should consider explicitly keeping the mentioned classes

[proguard] (using '-keep').

[proguard] (http://proguard.sourceforge.n...

[proguard] Note: there were 9 unresolved dynamic references to classes or interfaces.

[proguard] You should check if you need to specify additional program jars.

[proguard] (http://proguard.sourceforge.n...

[proguard] Note: there were 5 class casts of dynamically created class instances.

[proguard] You might consider explicitly keeping the mentioned classes and/or

[proguard] their implementations (using '-keep').

[proguard] (http://proguard.sourceforge.n...

[proguard] Note: there were 65 accesses to class members by means of introspection.

[proguard] You should consider explicitly keeping the mentioned class members

[proguard] (using '-keep' or '-keepclassmembers').

[proguard] (http://proguard.sourceforge.n...

[proguard] Note: you're ignoring all warnings!

[proguard] Ignoring unused library classes...

[proguard] Original number of library classes: 19879

[proguard] Final number of library classes: 19879

[proguard] Setting target versions...

[proguard] Printing kept classes, fields, and methods...

[proguard] Warning: there were 10914 unresolved references to classes or interfaces.

[proguard] You may need to add missing library jars or update their versions.

[proguard] If your code works fine without the missing classes, you can suppress

[proguard] the warnings with '-dontwarn' options.

[proguard] (http://proguard.sourceforge.n...

[proguard] Warning: there were 203 unresolved references to program class members.

[proguard] Your input classes appear to be inconsistent.

[proguard] You may need to recompile the code.

[proguard] (http://proguard.sourceforge.n...

[proguard] Warning: there were 26 unresolved references to library class members.

[proguard] You probably need to update the library versions.

[proguard] (http://proguard.sourceforge.n...

[proguard] Inlining subroutines...

[proguard] Obfuscating...

[proguard] Printing mapping to [C:UserswinIdeaProjects项目名targetproguard_map.txt]...

[proguard] Preverifying...

[proguard] Writing output...

[proguard] Preparing output war [C:UserswinIdeaProjects项目名target项目名-1.0-small.war]

[proguard] Copying resources from program war [C:UserswinIdeaProjects项目名target项目名-1.0.war] (filtered)

[INFO]

[INFO] --- maven-install-plugin:2.4:install (default-install) @ 项目名 ---

[INFO] Installing C:UserswinIdeaProjects项目名target项目名-1.0.war to C:Userswin.m2repositorycomsmart项目名1.0项目名-1.0.war

[INFO] Installing C:UserswinIdeaProjects项目名pom.xml to C:Userswin.m2repositorycomsmart项目名1.0项目名-1.0.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

proguard.conf文件的内容:

忽略警告

-ignorewarnings

打印处理信息,失败时会打印堆栈信息

-verbose

保持目录结构

-keepdirectories

不能混淆泛型、抛出的异常、注解默认值、原始行号等

-keepattributes Signature,Exceptions,Annotation,InnerClasses,Deprecated,EnclosingMethod

对于包名、类名不进行混淆

-keeppackagenames com.company.appname.**

保留public、protected方法不被混淆

-keep public class * {

public protected *;

}

保留注解不被混淆

-keep public @interface * {

** default (*);

}

保留枚举类不被混淆

-keepclassmembers enum * {

public static **[] values();

public static ** valueOf(java.lang.String);

}

保持依赖注入不被混淆

-keepclassmembers class * {

@org.springframework.beans.factory.annotation.Autowired *;

@javax.annotation.Resource *;

}

保持RMI调用不被混淆

-keep class * implements java.rmi.Remote {

(java.rmi.activation.ActivationID, java.rmi.MarshalledObject);

}

保留JavaBean不被混淆

-keepclassmembers class * implements java.io.Serializable {

static final long serialVersionUID;

private static final java.io.ObjectStreamField[] serialPersistentFields;

private void writeObject(java.io.ObjectOutputStream);

private void readObject(java.io.ObjectInputStream);

java.lang.Object writeReplace();

java.lang.Object readResolve();

}

避免类名被标记为final

-optimizations !class/marking/final

-target 1.8 ##指定java版本号

-dontshrink ##默认是开启的,这里关闭shrink,即不删除没有使用的类/成员

-dontoptimize ##默认是开启的,这里关闭字节码级别的优化

-useuniqueclassmembernames ##对于类成员的命名的混淆采取唯一策略

-adaptclassstrings ## 混淆类名之后,对使用Class.forName('className')之类的地方进行相应替代

-dontusemixedcaseclassnames ## 混淆时不生成大小写混合的类名,默认是可以大小写混合

pom.xml文件:

com.github.wvengen

proguard-maven-plugin

2.0.14

net.sf.proguard

proguard-base

5.3.3

runtime

package

proguard

5.3.3

true

项目名-1.0.war

项目名-1.0-small.war

${project.build.directory}

${project.basedir}/proguard.conf

${java.home}/lib/rt.jar

${java.home}/lib/jce.jar

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐