maven+proguard第三方jar打包混淆

几篇有价值的参考blog:

  1. http://blog.csdn.net/fastthinking/article/details/39155733(proguard基础 )
  2. http://www.tuicool.com/articles/QRzMz2(我是参照这篇配置的)
  3. http://www.blogjava.net/ideame/archive/2010/02/01/311486.html(混淆过程中报错, 看到了这篇文章,但最后发现我的问题跟他这个不一样)
  4. http://blog.csdn.net/testcs_dn/article/details/45623211(这个也不错)

环境:

Apache Maven 3.3.9 
Maven home: D:\Program Files\apache-maven-3.3.9
Java version: 1.8.0_74, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_74\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

我的maven配置

<plugins>
     <plugin>
         <artifactId>maven-assembly-pluginartifactId>
         <configuration>
             <archive>
                 <manifest>
                     
                     <mainClass>com.sq.platform.datacube.core.impl.DataCubemainClass>
                 manifest>
             archive>
             <descriptorRefs>
                 <descriptorRef>jar-with-dependenciesdescriptorRef>
             descriptorRefs>
         configuration>
         <executions>
             <execution>
                 <id>make-assemblyid> 
                 <phase>packagephase> 
                 <goals>
                     <goal>singlegoal>
                 goals>
             execution>
         executions>
     plugin>
     <plugin>
         <groupId>com.github.wvengengroupId>
         <artifactId>proguard-maven-pluginartifactId>
         <version>2.0.11version>
         <executions>
             <execution>
                 <phase>packagephase>
                 <goals>
                     <goal>proguardgoal>
                 goals>
             execution>
         executions>
         <configuration>
             <attach>trueattach>
             <attachArtifactClassifier>pgattachArtifactClassifier>
             
             <options> 
                 <option>-ignorewarningsoption> 
                 <option>-dontshrinkoption>   
                 <option>-dontoptimizeoption> 
                 <option>-dontskipnonpubliclibraryclasses option>
                 <option>-dontskipnonpubliclibraryclassmembers option>
                 <option>-dontnote option>

                 <option>-keepattributes Signatureoption>

                 
                 <option>-keepattributes Exceptions,InnerClasses,*Annotation*,Signature,LineNumberTableoption>


                                
                 <option>-keep class com.sq.platform.datacube.model.**option>
                 <option>-keepclassmembers class com.sq.platform.datacube.model.** { *;}option>
                 
                 <option>-keep class com.sq.platform.datacube.core.**option>
                 <option>-keepclassmembers class com.sq.platform.datacube.core.** { *;}option>

                 <option>-keep class com.sq.platform.datacube.exception.**option>
                 <option>-keepclassmembers class com.sq.platform.datacube.exception.** { *;}option>

                                
                 <option>-keepclassmembers class com.hopechart.dcroute.** { *;}option>
                 <option>-dontwarn com.hopechart.dcroute.**option>
                 <option>-keep class com.hopechart.dcroute.** {*;}option>

                 <option>-keepclassmembers class com.hopechart.cloud.** { *;}option>
                 <option>-dontwarn com.hopechart.cloud.**option>
                  <option>-keep class com.hopechart.cloud.** {*;}option>

                 <option>-keepclassmembers class com.hopechart.jcc.** { *;}option>
                 <option>-dontwarn com.hopechart.jcc.**option>
                 <option>-keep class com.hopechart.jcc.** {*;}option>

                 <option>-keepclassmembers class oracle.** { *;}option>
                 <option>-dontwarn oracle.**option>
                 <option>-keep class oracle.**option>

                 <option>-keepclassmembers class org.aopalliance.** { *;}option>
                 <option>-dontwarn org.aopalliance.**option>
                 <option>-keep class org.aopalliance.**option>

                 <option>-keepclassmembers class org.apache.commons.** { *;}option>
                 <option>-dontwarn org.apache.commons.**option>
                 <option>-keep class org.apache.commons.**option>

                 <option>-keepclassmembers class org.apache.log4j.** { *;}option>
                 <option>-dontwarn org.apache.log4j.**option>
                 <option>-keep class org.apache.log4j.**option>

                 <option>-keepclassmembers  class org.slf4j.** { *;}option>
                 <option>-dontwarn  org.slf4j.**option>
                 <option>-keep class org.slf4j.**option>

                 <option>-keepclassmembers class org.springframework.** { *;}option>
                 <option>-dontwarn  org.springframework.**option>
                 <option>-keep class org.springframework.**option>

             options>
             
             <injar>datacube-1.0-SNAPSHOT-jar-with-dependencies.jarinjar>
             
             <outjar>${project.build.finalName}-pgoutjar>
             <obfuscate>trueobfuscate>
             
             <libs>
                 <lib>${java.home}/lib/rt.jarlib>
                 <lib>${java.home}/lib/jce.jarlib>
                 <lib>D:/workspace3/datacube/lib/apache-axiom-api-1.2.7.jarlib>
                 <lib>D:/workspace3/datacube/lib/axis2-kernel-1.7.1.jarlib>
             libs>
         configuration>
     plugin>
plugins>

混淆后结果

maven+proguard第三方jar打包混淆_第1张图片

混淆中遇见的错误:

Error: Can’t find common super class of ………
解决方法:添加依赖的jar包

 <libs>
     <lib>${java.home}/lib/rt.jarlib>
     <lib>${java.home}/lib/jce.jarlib>
     <lib>D:/workspace3/datacube/lib/apache-axiom-api-1.2.7.jarlib>
     <lib>D:/workspace3/datacube/lib/axis2-kernel-1.7.1.jarlib>
 libs>

你可能感兴趣的:(Maven,maven,proguard,第三方jar打包,maven混淆)