summaryrefslogtreecommitdiff
path: root/examples/gradle/proguard.gradle
blob: 0abb72e89d2087fba64b0d78f8a62d5578c5d878 (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
//
// This Gradle build file illustrates how to process ProGuard itself.
// Configuration files for typical applications will be very similar.
// Usage:
//     gradle -b proguard.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 filter out the Ant classes, Gradle classes, and WTK classes, keeping
    // everything else.

    injars  '../../lib/proguard.jar', filter: '!proguard/ant/**,!proguard/gradle/**,!proguard/wtk/**'
    outjars 'proguard_out.jar'

    libraryjars "${System.getProperty('java.home')}/lib/rt.jar"

    // Write out an obfuscation mapping file, for de-obfuscating any stack traces
    // later on, or for incremental obfuscation of extensions.

    printmapping 'proguard.map'

    // 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 ''

    // Allow classes and class members to be made public.

    allowaccessmodification

    // The entry point: ProGuard and its main method.

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

    // If you want to preserve the Ant task as well, you'll have to specify the
    // main ant.jar.

    //libraryjars '/usr/local/java/ant/lib/ant.jar'
    //adaptresourcefilecontents 'proguard/ant/task.properties'
    //
    //keep allowobfuscation: true, 'class proguard.ant.*'
    //keepclassmembers 'public class proguard.ant.* { \
    //    <init>(org.apache.tools.ant.Project); \
    //    public void set*(***); \
    //    public void add*(***); \
    //}'

    // If you want to preserve the Gradle task, you'll have to specify the Gradle
    // jars.

    //libraryjars '/usr/local/java/gradle-2.1/lib/plugins/gradle-plugins-2.1.jar'
    //libraryjars '/usr/local/java/gradle-2.1/lib/gradle-base-services-2.1.jar'
    //libraryjars '/usr/local/java/gradle-2.1/lib/gradle-base-services-groovy-2.1.jar'
    //libraryjars '/usr/local/java/gradle-2.1/lib/gradle-core-2.1.jar'
    //libraryjars '/usr/local/java/gradle-2.1/lib/groovy-all-2.3.6.jar'

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

    // If you want to preserve the WTK obfuscation plug-in, you'll have to specify
    // the kenv.zip file.

    //libraryjars '/usr/local/java/wtk2.5.2/wtklib/kenv.zip'
    //keep 'public class proguard.wtk.ProGuardObfuscator'
}