Skip to content

Commit 2d7feeb

Browse files
committed
Обфускация при сборке
1 parent 9fb34ae commit 2d7feeb

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

build.xml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313

1414
<target name="package-for-store" depends="jar">
1515
<property name="store.jar.name" value="${application.title}"/>
16+
<property name="proguard.jar.path" value="store/proguard.jar" />
1617

1718
<property name="store.dir" value="store"/>
1819
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
20+
<property name="obfuscated.jar" value="${store.dir}/${store.jar.name}-obfuscated.jar"/>
1921

2022
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
2123

22-
<delete dir="${store.dir}"/>
24+
<delete file="${store.jar}"/>
25+
<delete file="${obfuscated.jar}"/>
2326
<mkdir dir="${store.dir}"/>
2427

2528
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
@@ -37,7 +40,26 @@
3740
</zip>
3841

3942
<delete file="${store.dir}/temp_final.jar"/>
43+
44+
45+
<echo message="Obfuscating ${store.jar}..." />
46+
47+
<taskdef resource="proguard/ant/task.properties"
48+
classpath="${proguard.jar.path}" />
49+
50+
<proguard configuration="proguard.properties">
51+
52+
<injar file="${store.jar}" />
53+
<outjar file="${store.dir}/temp_final.jar" />
54+
55+
<libraryjar path="${javac.classpath}" />
56+
<libraryjar file="${java.home}/lib/rt.jar" />
57+
58+
</proguard>
59+
60+
<move file="${store.dir}/temp_final.jar" tofile="${obfuscated.jar}"/>
4061
</target>
62+
4163
<!--
4264
4365
There exist several targets which are by default empty and which can be

proguard.properties

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
-target 1.8
2+
3+
-printmapping store/out.map
4+
-printusage store/out.txt
5+
-keepattributes Signature,InnerClasses
6+
-keepattributes *Annotation*
7+
8+
-dontwarn okio.**
9+
-dontwarn okhttp3.**
10+
11+
-keepclasseswithmembers public class * {
12+
public static void main(java.lang.String[]);
13+
}
14+
15+
-keep class okio.**
16+
-keep class okhttp3.** { *; }
17+
-keep interface okhttp3.** { *; }
18+
19+
-keepattributes Signature
20+
-keepattributes *Annotation*
21+
22+
-keepclassmembers enum * {
23+
public static **[] values();
24+
public static ** valueOf(java.lang.String);
25+
}
26+
27+
-keep class * extends javax.swing.plaf.ComponentUI {
28+
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent);
29+
}
30+
31+
-keepclasseswithmembers,includedescriptorclasses,allowshrinking class * {
32+
native <methods>;
33+
}
34+
35+
-keep public class * implements com.annimon.ownlang.lib.modules.Module
36+
37+
# Soft obfuscation
38+
-keep public class * {
39+
public protected *;
40+
}
41+
42+
# Hard obfuscation
43+
#-optimizationpasses 9
44+
#-allowaccessmodification
45+
#-dontusemixedcaseclassnames
46+
#-repackageclasses ''

0 commit comments

Comments
 (0)