summaryrefslogtreecommitdiff
path: root/examples/gradle/proguardall.gradle
blob: 561a455e7f21d5808a14029695daff6849398f8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// This Gradle build file illustrates how to process ProGuard
// (including its main application, its GUI, its Ant task, and its WTK plugin),
// and the ReTrace tool, all in one go.
// Configuration files for typical applications will be very similar.
// Usage:
//     gradle -b proguardall.gradle proguard
//

// Tell Gradle where to find the ProGuard task.

buildscript {
    repositories {
        flatDir dirs: '../../lib'
    }
    dependencies {
        classpath ':proguard'
    }
}

// Define a ProGuard task.

task proguard(type: proguard.gradle.ProGuardTask) {

    // You should probably import a more compact ProGuard-style configuration
    // file for all static settings, but we're specifying them all here, for
    // the sake of the example.
    //configuration 'configuration.pro'

    // Specify the input jars, output jars, and library jars.
    // We'll read all jars from the lib directory, process them, and write the
    // processed jars to a new out directory.

    injars  '../../lib'
    outjars 'out'

    // You may have to adapt the paths below.

    libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
    libraryjars '/usr/local/java/ant/lib/ant.jar'
    libraryjars '/usr/local/java/gradle-1.3/lib/plugins/gradle-plugins-1.3.jar'
    libraryjars '/usr/local/java/gradle-1.3/lib/gradle-base-services-1.3.jar'
    libraryjars '/usr/local/java/gradle-1.3/lib/gradle-core-1.3.jar'
    libraryjars '/usr/local/java/gradle-1.3/lib/groovy-all-1.8.6.jar'
    libraryjars '/usr/local/java/wtk2.5.2/wtklib/kenv.zip'

    // Allow methods with the same signature, except for the return type,
    // to get the same obfuscation name.

    overloadaggressively

    // Put all obfuscated classes into the nameless root package.

    repackageclasses ''

    // Adapt the names and contents of the resource files.

    adaptresourcefilenames    '**.properties,**.gif,**.jpg'
    adaptresourcefilecontents 'proguard/ant/task.properties'

    // The main entry points.

    keep 'public class proguard.ProGuard { \
        public static void main(java.lang.String[]); \
    }'

    keep 'public class proguard.gui.ProGuardGUI { \
        public static void main(java.lang.String[]); \
    }'

    keep 'public class proguard.retrace.ReTrace { \
        public static void main(java.lang.String[]); \
    }'

    // If we have ant.jar, we can properly process the Ant task.

    keep allowobfuscation: true, 'class proguard.ant.*'
    keepclassmembers 'public class proguard.ant.* { \
        <init>(org.apache.tools.ant.Project); \
        public void set*(***); \
        public void add*(***); \
    }'

    // If we have the Gradle jars, we can properly process the Gradle task.

    keep 'public class proguard.gradle.* { \
        public *; \
    }'

    // If we have kenv.zip, we can process the J2ME WTK plugin.

    keep 'public class proguard.wtk.ProGuardObfuscator'
}