2016-11-11 5 views
1

Jungs, ich versuche, eine .jar-Anwendung mit dem Proguard-Maven-Plugin zu verschleiern.
Wenn ich versuche, den Verschleierungsprozess auszuführen, erhalte ich Fehlermeldungen, die angeben, dass unerwartete Klassen vorhanden sind.ProGuard + Spring Boot + Maven Plugin

Ich verwende den Spring Boot 1.4.1.RELEASE und das Proguard Maven Plugin 2.0.13.

Das ist mein proguard.conf

-injars /workspace/base/target/test-1.0.0.jar 

-libraryjars /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre/lib/rt.jar 

-dontshrink 
-dontoptimize 
-dontobfuscate 
-dontusemixedcaseclassnames 
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod 

-adaptresourcefilenames **.properties 
-adaptresourcefilecontents **.properties,META-INF/MANIFEST.MF 

-dontpreverify 
-verbose 


-keepclasseswithmembers public class * { 
    public static void main(java.lang.String[]); 
} 

-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 

-keep class * extends java.beans.BeanInfo 

-keep class * { 
    void set*(***); 
    void set*(int,***); 
    boolean is*(); 
    boolean is*(int); 
    *** get*(); 
    *** get*(int); 
} 

-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(); 
    public static java.util.Properties getProperties(); 
    public static java.lang.String getProperty(java.lang.String); 
    public static java.lang.String getenv(java.lang.String); 
    public static java.lang.String mapLibraryName(java.lang.String); 
    public static java.lang.String getProperty(java.lang.String,java.lang.String); 
} 

Die pom.xml Datei. Ich informiere die Konfiguration nur über das Plugin.

<plugin> 
    <groupId>com.github.wvengen</groupId> 
    <artifactId>proguard-maven-plugin</artifactId> 
    <version>2.0.13</version> 
    <executions> 
     <execution> 
      <phase>package</phase> 
      <goals> 
       <goal>proguard</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <obfuscate>false</obfuscate> 
     <outFilter>**/BOOT-INF/classes/ **.class</outFilter> 

     <proguardInclude>${basedir}/proguard.conf</proguardInclude> 
     <outputDirectory>${project.build.directory}</outputDirectory> 

     <injar>${project.build.finalName}.jar</injar> 
     <outjar>${project.build.finalName}-min.jar</outjar> 
    </configuration> 
</plugin> 

jedoch während des Ausführungsprozesses erhalte ich die folgende Rückkehr für alle Klassen in meiner Anwendung.

Warning: class [BOOT-INF/classes/br/com/base/BaseApplication.class] unexpectedly contains class [br.com.base.BaseApplication] 
Warning: class [BOOT-INF/classes/br/com/base/controller/CaixaController.class] unexpectedly contains class [br.com.base.controller.CaixaController] 
[...] 

Und die endgültige Ausgabe von ProGuard. PS: Alle Klassen sind in der BOOT-INF/classes Verzeichnis

Warning: there were 97 classes in incorrectly named files. 
You should make sure all file names correspond to their class names. 
The directory hierarchies must correspond to the package hierarchies. 
    (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass) 
If you don't mind the mentioned classes not being written out, 
you could try your luck using the '-ignorewarnings' option. 
Please correct the above warnings first. 

Kann jemand irgendwelche Alternativen vorstellen, ich versuchen kann? Danke.

Antwort

4

Um dies zu beheben, habe ich die Reihenfolge der Plugins in der Pom geändert. Das Proguard-Plugin sollte zuerst gehen, gefolgt von dem Spring-Boot-Plugin.

Stellen Sie außerdem sicher, dass Sie die <goal>repackage</goal> in der Spring Boot-Konfiguration angegeben haben. Mit der richtigen Reihenfolge und dem angegebenen Umpackziel werden die Progroard-Verschleierung/-Optimierung/was auch immer Sie konfiguriert haben, durchgeführt und ein Jar erzeugt. Dann wird das Spring-Boot-Plugin dieses Jar als ausführbare Datei neu packen und alles sollte funktionieren.

Mein Plugin-Konfiguration von pom.xml:

<project ...> 
.... 
<plugin> 
    <groupId>com.github.wvengen</groupId> 
    <artifactId>proguard-maven-plugin</artifactId> 
    <executions> 
     <execution> 
      <phase>package</phase> 
      <goals> 
       <goal>proguard</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <proguardInclude>${basedir}/proguard.conf</proguardInclude> 
     <libs> 
      <lib>${java.home}/lib/rt.jar</lib> 
      <lib>${java.home}/lib/jce.jar</lib> 
     </libs> 
    </configuration> 
</plugin> 
<plugin> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-maven-plugin</artifactId> 
    <executions> 
     <execution> 
      <goals> 
       <goal>repackage</goal> 
      </goals> 
      <configuration> 
       <start-class>org.springframework.boot.loader.JarLauncher</start-class> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
... 
Verwandte Themen