Обфускация при сборке

This commit is contained in:
Victor 2016-02-19 21:50:52 +02:00
parent 9fb34ae09b
commit 2d7feeb0cd
2 changed files with 69 additions and 1 deletions

View File

@ -13,13 +13,16 @@
<target name="package-for-store" depends="jar"> <target name="package-for-store" depends="jar">
<property name="store.jar.name" value="${application.title}"/> <property name="store.jar.name" value="${application.title}"/>
<property name="proguard.jar.path" value="store/proguard.jar" />
<property name="store.dir" value="store"/> <property name="store.dir" value="store"/>
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/> <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
<property name="obfuscated.jar" value="${store.dir}/${store.jar.name}-obfuscated.jar"/>
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/> <echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
<delete dir="${store.dir}"/> <delete file="${store.jar}"/>
<delete file="${obfuscated.jar}"/>
<mkdir dir="${store.dir}"/> <mkdir dir="${store.dir}"/>
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip"> <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
@ -37,7 +40,26 @@
</zip> </zip>
<delete file="${store.dir}/temp_final.jar"/> <delete file="${store.dir}/temp_final.jar"/>
<echo message="Obfuscating ${store.jar}..." />
<taskdef resource="proguard/ant/task.properties"
classpath="${proguard.jar.path}" />
<proguard configuration="proguard.properties">
<injar file="${store.jar}" />
<outjar file="${store.dir}/temp_final.jar" />
<libraryjar path="${javac.classpath}" />
<libraryjar file="${java.home}/lib/rt.jar" />
</proguard>
<move file="${store.dir}/temp_final.jar" tofile="${obfuscated.jar}"/>
</target> </target>
<!-- <!--
There exist several targets which are by default empty and which can be There exist several targets which are by default empty and which can be

46
proguard.properties Normal file
View File

@ -0,0 +1,46 @@
-target 1.8
-printmapping store/out.map
-printusage store/out.txt
-keepattributes Signature,InnerClasses
-keepattributes *Annotation*
-dontwarn okio.**
-dontwarn okhttp3.**
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}
-keep class okio.**
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-keepattributes Signature
-keepattributes *Annotation*
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * extends javax.swing.plaf.ComponentUI {
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent);
}
-keepclasseswithmembers,includedescriptorclasses,allowshrinking class * {
native <methods>;
}
-keep public class * implements com.annimon.ownlang.lib.modules.Module
# Soft obfuscation
-keep public class * {
public protected *;
}
# Hard obfuscation
#-optimizationpasses 9
#-allowaccessmodification
#-dontusemixedcaseclassnames
#-repackageclasses ''