• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// This Gradle build file illustrates how to process J2ME midlets.
3// Usage:
4//     gradle -b midlets.gradle proguard
5//
6
7// Tell Gradle where to find the ProGuard task.
8
9buildscript {
10    repositories {
11        flatDir dirs: '../../lib'
12    }
13    dependencies {
14        classpath ':proguard'
15    }
16}
17
18// Define a ProGuard task.
19
20task proguard(type: proguard.gradle.ProGuardTask) {
21
22    // You should probably import a more compact ProGuard-style configuration
23    // file for all static settings, but we're specifying them all here, for
24    // the sake of the example.
25    //configuration 'configuration.pro'
26
27    // Specify the input jars, output jars, and library jars.
28
29    injars  'in.jar'
30    outjars 'out.jar'
31
32    libraryjars '/usr/local/java/wtk2.5.2/lib/midpapi20.jar'
33    libraryjars '/usr/local/java/wtk2.5.2/lib/cldcapi11.jar'
34
35    // Preverify the code suitably for Java Micro Edition.
36
37    microedition
38
39    // Allow methods with the same signature, except for the return type,
40    // to get the same obfuscation name.
41
42    overloadaggressively
43
44    // Put all obfuscated classes into the nameless root package.
45
46    repackageclasses ''
47
48    // Allow classes and class members to be made public.
49
50    allowaccessmodification
51
52    // On Windows, you can't use mixed case class names,
53    // should you still want to use the preverify tool.
54    //
55    // dontusemixedcaseclassnames
56
57    // Save the obfuscation mapping to a file, so you can de-obfuscate any stack
58    // traces later on.
59
60    printmapping 'out.map'
61
62    // You can keep a fixed source file attribute and all line number tables to
63    // get stack traces with line numbers.
64
65    //renamesourcefileattribute 'SourceFile'
66    //keepattributes 'SourceFile,LineNumberTable'
67
68    // You can print out the seeds that are matching the keep options below.
69
70    //printseeds 'out.seeds'
71
72    // Preserve all public midlets.
73
74    keep 'public class * extends javax.microedition.midlet.MIDlet'
75
76    // Preserve all native method names and the names of their classes.
77
78    keepclasseswithmembernames includedescriptorclasses:true, 'class * { \
79        native <methods>; \
80    }'
81
82    // Your midlet may contain more items that need to be preserved;
83    // typically classes that are dynamically created using Class.forName:
84
85    // keep 'public class mypackage.MyClass'
86    // keep 'public interface mypackage.MyInterface'
87    // keep 'public class * implements mypackage.MyInterface'
88}
89