Home | History | Annotate | Download | only in gradle
      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 
     12 buildscript {
     13     repositories {
     14         flatDir dirs: '../../lib'
     15     }
     16     dependencies {
     17         classpath ':proguard'
     18     }
     19 }
     20 
     21 // Define a ProGuard task.
     22 
     23 task 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-1.3/lib/plugins/gradle-plugins-1.3.jar'
     42     libraryjars '/usr/local/java/gradle-1.3/lib/gradle-base-services-1.3.jar'
     43     libraryjars '/usr/local/java/gradle-1.3/lib/gradle-core-1.3.jar'
     44     libraryjars '/usr/local/java/gradle-1.3/lib/groovy-all-1.8.6.jar'
     45     libraryjars '/usr/local/java/wtk2.5.2/wtklib/kenv.zip'
     46 
     47     // Allow methods with the same signature, except for the return type,
     48     // to get the same obfuscation name.
     49 
     50     overloadaggressively
     51 
     52     // Put all obfuscated classes into the nameless root package.
     53 
     54     repackageclasses ''
     55 
     56     // Adapt the names and contents of the resource files.
     57 
     58     adaptresourcefilenames    '**.properties,**.gif,**.jpg'
     59     adaptresourcefilecontents 'proguard/ant/task.properties'
     60 
     61     // The main entry points.
     62 
     63     keep 'public class proguard.ProGuard { \
     64         public static void main(java.lang.String[]); \
     65     }'
     66 
     67     keep 'public class proguard.gui.ProGuardGUI { \
     68         public static void main(java.lang.String[]); \
     69     }'
     70 
     71     keep 'public class proguard.retrace.ReTrace { \
     72         public static void main(java.lang.String[]); \
     73     }'
     74 
     75     // If we have ant.jar, we can properly process the Ant task.
     76 
     77     keep allowobfuscation: true, 'class proguard.ant.*'
     78     keepclassmembers 'public class proguard.ant.* { \
     79         <init>(org.apache.tools.ant.Project); \
     80         public void set*(***); \
     81         public void add*(***); \
     82     }'
     83 
     84     // If we have the Gradle jars, we can properly process the Gradle task.
     85 
     86     keep 'public class proguard.gradle.* { \
     87         public *; \
     88     }'
     89 
     90     // If we have kenv.zip, we can process the J2ME WTK plugin.
     91 
     92     keep 'public class proguard.wtk.ProGuardObfuscator'
     93 }
     94