1//
2// This Gradle build file illustrates how to process ProGuard
3// (including its main application, its GUI, its Ant task, and its WTK plugin),
4// and the ReTrace tool, all in one go.
5// Configuration files for typical applications will be very similar.
6// Usage:
7//     gradle -b proguardall.gradle proguard
8//
9
10// Tell Gradle where to find the ProGuard task.
11
12buildscript {
13    repositories {
14        flatDir dirs: '../../lib'
15    }
16    dependencies {
17        classpath ':proguard'
18    }
19}
20
21// Define a ProGuard task.
22
23task proguard(type: proguard.gradle.ProGuardTask) {
24
25    // You should probably import a more compact ProGuard-style configuration
26    // file for all static settings, but we're specifying them all here, for
27    // the sake of the example.
28    //configuration 'configuration.pro'
29
30    // Specify the input jars, output jars, and library jars.
31    // We'll read all jars from the lib directory, process them, and write the
32    // processed jars to a new out directory.
33
34    injars  '../../lib'
35    outjars 'out'
36
37    // You may have to adapt the paths below.
38
39    libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
40    libraryjars '/usr/local/java/ant/lib/ant.jar'
41    libraryjars '/usr/local/java/gradle-2.1/lib/plugins/gradle-plugins-2.1.jar'
42    libraryjars '/usr/local/java/gradle-2.1/lib/gradle-base-services-2.1.jar'
43    libraryjars '/usr/local/java/gradle-2.1/lib/gradle-base-services-groovy-2.1.jar'
44    libraryjars '/usr/local/java/gradle-2.1/lib/gradle-core-2.1.jar'
45    libraryjars '/usr/local/java/gradle-2.1/lib/groovy-all-2.3.6.jar'
46    libraryjars '/usr/local/java/wtk2.5.2/wtklib/kenv.zip'
47
48    // Allow methods with the same signature, except for the return type,
49    // to get the same obfuscation name.
50
51    overloadaggressively
52
53    // Put all obfuscated classes into the nameless root package.
54
55    repackageclasses ''
56
57    // Adapt the names and contents of the resource files.
58
59    adaptresourcefilenames    '**.properties,**.gif,**.jpg'
60    adaptresourcefilecontents 'proguard/ant/task.properties'
61
62    // The main entry points.
63
64    keep 'public class proguard.ProGuard { \
65        public static void main(java.lang.String[]); \
66    }'
67
68    keep 'public class proguard.gui.ProGuardGUI { \
69        public static void main(java.lang.String[]); \
70    }'
71
72    keep 'public class proguard.retrace.ReTrace { \
73        public static void main(java.lang.String[]); \
74    }'
75
76    // If we have ant.jar, we can properly process the Ant task.
77
78    keep allowobfuscation: true, 'class proguard.ant.*'
79    keepclassmembers 'public class proguard.ant.* { \
80        <init>(org.apache.tools.ant.Project); \
81        public void set*(***); \
82        public void add*(***); \
83    }'
84
85    // If we have the Gradle jars, we can properly process the Gradle task.
86
87    keep 'public class proguard.gradle.* { \
88        public *; \
89    }'
90
91    // If we have kenv.zip, we can process the J2ME WTK plugin.
92
93    keep 'public class proguard.wtk.ProGuardObfuscator'
94}
95