diff options
Diffstat (limited to 'examples/gradle')
-rw-r--r-- | examples/gradle/android.gradle | 195 | ||||
-rw-r--r-- | examples/gradle/applets.gradle | 90 | ||||
-rw-r--r-- | examples/gradle/applications.gradle | 96 | ||||
-rw-r--r-- | examples/gradle/library.gradle | 99 | ||||
-rw-r--r-- | examples/gradle/midlets.gradle | 88 | ||||
-rw-r--r-- | examples/gradle/proguard.gradle | 91 | ||||
-rw-r--r-- | examples/gradle/proguardall.gradle | 93 | ||||
-rw-r--r-- | examples/gradle/proguardgui.gradle | 72 | ||||
-rw-r--r-- | examples/gradle/retrace.gradle | 64 | ||||
-rw-r--r-- | examples/gradle/scala.gradle | 153 | ||||
-rw-r--r-- | examples/gradle/servlets.gradle | 91 |
11 files changed, 1132 insertions, 0 deletions
diff --git a/examples/gradle/android.gradle b/examples/gradle/android.gradle new file mode 100644 index 0000000..4e950d5 --- /dev/null +++ b/examples/gradle/android.gradle @@ -0,0 +1,195 @@ +// +// This Gradle build file illustrates how to process Android +// applications. +// Usage: +// gradle -b android.gradle proguard +// +// If you're using the Android SDK, the Ant release build and Eclipse export +// already take care of the proper settings. You only need to enable ProGuard +// by commenting in the corresponding line in project.properties. You can still +// add project-specific configuration in proguard-project.txt. +// +// This configuration file is for custom, stand-alone builds. + +// 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. + // Note that ProGuard works with Java bytecode (.class), + // before the dex compiler converts it into Dalvik code (.dex). + + injars 'bin/classes' + injars 'libs' + outjars 'bin/classes-processed.jar' + + libraryjars '/usr/local/android-sdk/platforms/android-9/android.jar' + //libraryjars '/usr/local/android-sdk/add-ons/google_apis-7_r01/libs/maps.jar' + // ... + + // Save the obfuscation mapping to a file, so you can de-obfuscate any stack + // traces later on. + + printmapping 'bin/classes-processed.map' + + // You can print out the seeds that are matching the keep options below. + + //printseeds 'bin/classes-processed.seeds' + + // Preverification is irrelevant for the dex compiler and the Dalvik VM. + + dontpreverify + + // Reduce the size of the output some more. + + repackageclasses '' + allowaccessmodification + + // Switch off some optimizations that trip older versions of the Dalvik VM. + + optimizations '!code/simplification/arithmetic' + + // Keep a fixed source file attribute and all line number tables to get line + // numbers in the stack traces. + // You can comment this out if you're not interested in stack traces. + + renamesourcefileattribute 'SourceFile' + keepattributes 'SourceFile,LineNumberTable' + + // RemoteViews might need annotations. + + keepattributes '*Annotation*' + + // Preserve all fundamental application classes. + + keep 'public class * extends android.app.Activity' + keep 'public class * extends android.app.Application' + keep 'public class * extends android.app.Service' + keep 'public class * extends android.content.BroadcastReceiver' + keep 'public class * extends android.content.ContentProvider' + + // Preserve all View implementations, their special context constructors, and + // their setters. + + keep 'public class * extends android.view.View { \ + public <init>(android.content.Context); \ + public <init>(android.content.Context, android.util.AttributeSet); \ + public <init>(android.content.Context, android.util.AttributeSet, int); \ + public void set*(...); \ + }' + + // Preserve all classes that have special context constructors, and the + // constructors themselves. + + keepclasseswithmembers 'class * { \ + public <init>(android.content.Context, android.util.AttributeSet); \ + }' + + // Preserve all classes that have special context constructors, and the + // constructors themselves. + + keepclasseswithmembers 'class * { \ + public <init>(android.content.Context, android.util.AttributeSet, int); \ + }' + + // Preserve all possible onClick handlers. + + keepclassmembers 'class * extends android.content.Context { \ + public void *(android.view.View); \ + public void *(android.view.MenuItem); \ + }' + + // Preserve the special fields of all Parcelable implementations. + + keepclassmembers 'class * implements android.os.Parcelable { \ + static android.os.Parcelable$Creator CREATOR; \ + }' + + // Preserve static fields of inner classes of R classes that might be accessed + // through introspection. + + keepclassmembers 'class **.R$* { \ + public static <fields>; \ + }' + + // Preserve annotated Javascript interface methods. + + keepclassmembers 'class * { \ + @android.webkit.JavascriptInterface <methods>; \ + }' + + // Preserve the required interface from the License Verification Library + // (but don't nag the developer if the library is not used at all). + + keep 'public interface com.android.vending.licensing.ILicensingService' + + dontnote 'com.android.vending.licensing.ILicensingService' + + // The Android Compatibility library references some classes that may not be + // present in all versions of the API, but we know that's ok. + + dontwarn 'android.support.**' + + // Preserve all native method names and the names of their classes. + + keepclasseswithmembernames 'class * { \ + native <methods>; \ + }' + + // Preserve the special static methods that are required in all enumeration + // classes. + + keepclassmembers 'class * extends java.lang.Enum { \ + public static **[] values(); \ + public static ** valueOf(java.lang.String); \ + }' + + // Explicitly preserve all serialization members. The Serializable interface + // is only a marker interface, so it wouldn't save them. + // You can comment this out if your application doesn't use serialization. + // If your code contains serializable classes that have to be backward + // compatible, please refer to the manual. + + keepclassmembers 'class * implements java.io.Serializable { \ + static final long serialVersionUID; \ + static final java.io.ObjectStreamField[] serialPersistentFields; \ + private void writeObject(java.io.ObjectOutputStream); \ + private void readObject(java.io.ObjectInputStream); \ + java.lang.Object writeReplace(); \ + java.lang.Object readResolve(); \ + }' + + // Your application may contain more items that need to be preserved; + // typically classes that are dynamically created using Class.forName: + + //keep 'public class mypackage.MyClass' + //keep 'public interface mypackage.MyInterface' + //keep 'public class * implements mypackage.MyInterface' + + // If you wish, you can let the optimization step remove Android logging + // calls. + //assumenosideeffects class android.util.Log { + // public static boolean isLoggable(java.lang.String, int); + // public static int v(...); + // public static int i(...); + // public static int w(...); + // public static int d(...); + // public static int e(...); + //} +} diff --git a/examples/gradle/applets.gradle b/examples/gradle/applets.gradle new file mode 100644 index 0000000..29c8559 --- /dev/null +++ b/examples/gradle/applets.gradle @@ -0,0 +1,90 @@ +// +// This Gradle build file illustrates how to process applets. +// Usage: +// gradle -b applets.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. + + injars 'in.jar' + outjars 'out.jar' + + libraryjars "${System.getProperty('java.home')}/lib/rt.jar" + + // Save the obfuscation mapping to a file, so you can de-obfuscate any stack + // traces later on. Keep a fixed source file attribute and all line number + // tables to get line numbers in the stack traces. + // You can comment this out if you're not interested in stack traces. + + printmapping 'out.map' + renamesourcefileattribute 'SourceFile' + keepattributes 'SourceFile,LineNumberTable' + + // Preserve all annotations. + + keepattributes '*Annotation*' + + // You can print out the seeds that are matching the keep options below. + + //printseeds 'out.seeds' + + // Preserve all public applets. + + keep 'public class * extends java.applet.Applet' + + // Preserve all native method names and the names of their classes. + + keepclasseswithmembernames 'class * { \ + native <methods>; \ + }' + + // Preserve the special static methods that are required in all enumeration + // classes. + + keepclassmembers 'class * extends java.lang.Enum { \ + public static **[] values(); \ + public static ** valueOf(java.lang.String); \ + }' + + // Explicitly preserve all serialization members. The Serializable interface + // is only a marker interface, so it wouldn't save them. + // You can comment this out if your library doesn't use serialization. + // If your code contains serializable classes that have to be backward + // compatible, please refer to the manual. + + keepclassmembers 'class * implements java.io.Serializable { \ + static final long serialVersionUID; \ + static final java.io.ObjectStreamField[] serialPersistentFields; \ + private void writeObject(java.io.ObjectOutputStream); \ + private void readObject(java.io.ObjectInputStream); \ + java.lang.Object writeReplace(); \ + java.lang.Object readResolve(); \ + }' + + // Your application may contain more items that need to be preserved; + // typically classes that are dynamically created using Class.forName: + + // keep 'public class mypackage.MyClass' + // keep 'public interface mypackage.MyInterface' + // keep 'public class * implements mypackage.MyInterface' +} diff --git a/examples/gradle/applications.gradle b/examples/gradle/applications.gradle new file mode 100644 index 0000000..73dfdf0 --- /dev/null +++ b/examples/gradle/applications.gradle @@ -0,0 +1,96 @@ +// +// This Gradle build file illustrates how to process applications. +// Usage: +// gradle -b applications.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. + + injars 'in.jar' + outjars 'out.jar' + + libraryjars "${System.getProperty('java.home')}/lib/rt.jar" + //libraryjars 'junit.jar' + //libraryjars 'servlet.jar' + //libraryjars 'jai_core.jar' + //... + + // Save the obfuscation mapping to a file, so you can de-obfuscate any stack + // traces later on. Keep a fixed source file attribute and all line number + // tables to get line numbers in the stack traces. + // You can comment this out if you're not interested in stack traces. + + printmapping 'out.map' + renamesourcefileattribute 'SourceFile' + keepattributes 'SourceFile,LineNumberTable' + + // Preserve all annotations. + + keepattributes '*Annotation*' + + // You can print out the seeds that are matching the keep options below. + + //printseeds 'out.seeds' + + // Preserve all public applications. + + keepclasseswithmembers 'public class * { \ + public static void main(java.lang.String[]); \ + }' + + // Preserve all native method names and the names of their classes. + + keepclasseswithmembernames 'class * { \ + native <methods>; \ + }' + + // Preserve the special static methods that are required in all enumeration + // classes. + + keepclassmembers 'class * extends java.lang.Enum { \ + public static **[] values(); \ + public static ** valueOf(java.lang.String); \ + }' + + // Explicitly preserve all serialization members. The Serializable interface + // is only a marker interface, so it wouldn't save them. + // You can comment this out if your application doesn't use serialization. + // If your code contains serializable classes that have to be backward + // compatible, please refer to the manual. + + keepclassmembers 'class * implements java.io.Serializable { \ + static final long serialVersionUID; \ + static final java.io.ObjectStreamField[] serialPersistentFields; \ + private void writeObject(java.io.ObjectOutputStream); \ + private void readObject(java.io.ObjectInputStream); \ + java.lang.Object writeReplace(); \ + java.lang.Object readResolve(); \ + }' + + // Your application may contain more items that need to be preserved; + // typically classes that are dynamically created using Class.forName: + + // keep 'public class mypackage.MyClass' + // keep 'public interface mypackage.MyInterface' + // keep 'public class * implements mypackage.MyInterface' +} diff --git a/examples/gradle/library.gradle b/examples/gradle/library.gradle new file mode 100644 index 0000000..2f68962 --- /dev/null +++ b/examples/gradle/library.gradle @@ -0,0 +1,99 @@ +// +// This Gradle build file illustrates how to process a program +// library, such that it remains usable as a library. +// Usage: +// gradle -b library.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. + // In this case, the input jar is the program library that we want to process. + + injars 'in.jar' + outjars 'out.jar' + + libraryjars "${System.getProperty('java.home')}/lib/rt.jar" + + // Save the obfuscation mapping to a file, so we can de-obfuscate any stack + // traces later on. Keep a fixed source file attribute and all line number + // tables to get line numbers in the stack traces. + // You can comment this out if you're not interested in stack traces. + + printmapping 'out.map' + keepparameternames + renamesourcefileattribute 'SourceFile' + keepattributes 'Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,EnclosingMethod' + + // Preserve all annotations. + + keepattributes '*Annotation*' + + // Preserve all public classes, and their public and protected fields and + // methods. + + keep 'public class * { \ + public protected *; \ + }' + + // Preserve all .class method names. + + keepclassmembernames 'class * { \ + java.lang.Class class$(java.lang.String); \ + java.lang.Class class$(java.lang.String, boolean); \ + }' + + // Preserve all native method names and the names of their classes. + + keepclasseswithmembernames 'class * { \ + native <methods>; \ + }' + + // Preserve the special static methods that are required in all enumeration + // classes. + + keepclassmembers 'class * extends java.lang.Enum { \ + public static **[] values(); \ + public static ** valueOf(java.lang.String); \ + }' + + // Explicitly preserve all serialization members. The Serializable interface + // is only a marker interface, so it wouldn't save them. + // You can comment this out if your library doesn't use serialization. + // If your code contains serializable classes that have to be backward + // compatible, please refer to the manual. + + keepclassmembers 'class * implements java.io.Serializable { \ + static final long serialVersionUID; \ + static final java.io.ObjectStreamField[] serialPersistentFields; \ + private void writeObject(java.io.ObjectOutputStream); \ + private void readObject(java.io.ObjectInputStream); \ + java.lang.Object writeReplace(); \ + java.lang.Object readResolve(); \ + }' + + // Your library may contain more items that need to be preserved; + // typically classes that are dynamically created using Class.forName: + + // keep 'public class mypackage.MyClass' + // keep 'public interface mypackage.MyInterface' + // keep 'public class * implements mypackage.MyInterface' +} diff --git a/examples/gradle/midlets.gradle b/examples/gradle/midlets.gradle new file mode 100644 index 0000000..dffb2c3 --- /dev/null +++ b/examples/gradle/midlets.gradle @@ -0,0 +1,88 @@ +// +// This Gradle build file illustrates how to process J2ME midlets. +// Usage: +// gradle -b midlets.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. + + injars 'in.jar' + outjars 'out.jar' + + libraryjars '/usr/local/java/wtk2.5.2/lib/midpapi20.jar' + libraryjars '/usr/local/java/wtk2.5.2/lib/cldcapi11.jar' + + // Preverify the code suitably for Java Micro Edition. + + microedition + + // 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 + + // On Windows, you can't use mixed case class names, + // should you still want to use the preverify tool. + // + // dontusemixedcaseclassnames + + // Save the obfuscation mapping to a file, so you can de-obfuscate any stack + // traces later on. + + printmapping 'out.map' + + // You can keep a fixed source file attribute and all line number tables to + // get stack traces with line numbers. + + //renamesourcefileattribute 'SourceFile' + //keepattributes 'SourceFile,LineNumberTable' + + // You can print out the seeds that are matching the keep options below. + + //printseeds 'out.seeds' + + // Preserve all public midlets. + + keep 'public class * extends javax.microedition.midlet.MIDlet' + + // Preserve all native method names and the names of their classes. + + keepclasseswithmembernames 'class * { \ + native <methods>; \ + }' + + // Your midlet may contain more items that need to be preserved; + // typically classes that are dynamically created using Class.forName: + + // keep 'public class mypackage.MyClass' + // keep 'public interface mypackage.MyInterface' + // keep 'public class * implements mypackage.MyInterface' +} diff --git a/examples/gradle/proguard.gradle b/examples/gradle/proguard.gradle new file mode 100644 index 0000000..8974f93 --- /dev/null +++ b/examples/gradle/proguard.gradle @@ -0,0 +1,91 @@ +// +// 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-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' + + //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' +} diff --git a/examples/gradle/proguardall.gradle b/examples/gradle/proguardall.gradle new file mode 100644 index 0000000..561a455 --- /dev/null +++ b/examples/gradle/proguardall.gradle @@ -0,0 +1,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' +} diff --git a/examples/gradle/proguardgui.gradle b/examples/gradle/proguardgui.gradle new file mode 100644 index 0000000..7bfebd9 --- /dev/null +++ b/examples/gradle/proguardgui.gradle @@ -0,0 +1,72 @@ +// +// This Gradle build file illustrates how to process the ProGuard GUI. +// Configuration files for typical applications will be very similar. +// Usage: +// gradle -b proguardgui.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. + // The input jars will be merged in a single output jar. + // We'll filter out the Ant classes, Gradle classes, and WTK classes, keeping + // everything else. + + injars '../../lib/proguardgui.jar' + injars '../../lib/proguard.jar', filter: '!META-INF/**,!proguard/ant/**,!proguard/gradle/**,!proguard/wtk/**' + injars '../../lib/retrace.jar', filter: '!META-INF/**' + outjars 'proguardgui_out.jar' + + libraryjars "${System.getProperty('java.home')}/lib/rt.jar" + + // If we wanted to reuse the previously obfuscated proguard_out.jar, we could + // perform incremental obfuscation based on its mapping file, and only keep the + // additional GUI files instead of all files. + + //applymapping 'proguard.map' + //injars '../../lib/proguardgui.jar' + //outjars 'proguardgui_out.jar' + //libraryjars '../../lib/proguard.jar', filter: '!proguard/ant/**,!proguard/wtk/**' + //libraryjars '../../lib/retrace.jar' + //libraryjars "${System.getProperty('java.home')}/lib/rt.jar" + + + // 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 of resource files, based on the corresponding obfuscated + // class names. Notably, in this case, the GUI resource properties file will + // have to be renamed. + + adaptresourcefilenames '**.properties,**.gif,**.jpg' + + // The entry point: ProGuardGUI and its main method. + + keep 'public class proguard.gui.ProGuardGUI { \ + public static void main(java.lang.String[]); \ + }' +} diff --git a/examples/gradle/retrace.gradle b/examples/gradle/retrace.gradle new file mode 100644 index 0000000..7fe2c7e --- /dev/null +++ b/examples/gradle/retrace.gradle @@ -0,0 +1,64 @@ +// +// This Gradle build file illustrates how to process the ReTrace tool. +// Configuration files for typical applications will be very similar. +// Usage: +// gradle -b retrace.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. + // The input jars will be merged in a single output jar. + // We'll filter out the Ant and WTK classes. + + injars '../../lib/retrace.jar' + injars '../../lib/proguard.jar(!META-INF/MANIFEST.MF,' + !proguard/ant/**,!proguard/wtk/**) + outjars 'retrace_out.jar' + + libraryjars "${System.getProperty('java.home')}/lib/rt.jar" + + // If we wanted to reuse the previously obfuscated proguard_out.jar, we could + // perform incremental obfuscation based on its mapping file, and only keep the + // additional ReTrace files instead of all files. + + //applymapping 'proguard.map' + //outjars 'retrace_out.jar', filter: 'proguard/retrace/**' + + // 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: ReTrace and its main method. + + keep 'public class proguard.retrace.ReTrace { \ + public static void main(java.lang.String[]); \ + }' +} diff --git a/examples/gradle/scala.gradle b/examples/gradle/scala.gradle new file mode 100644 index 0000000..286e5e9 --- /dev/null +++ b/examples/gradle/scala.gradle @@ -0,0 +1,153 @@ +// +// This Gradle build file illustrates how to process Scala +// applications, including the Scala runtime. +// Usage: +// gradle -b scala.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. + + injars 'in.jar' + injars '/usr/local/java/scala-2.9.1/lib/scala-library.jar' + //injars '/usr/local/java/scala-2.9.1/lib/scala-compiler.jar', filter: '!META-INF/MANIFEST.MF' + //injars '/usr/local/java/scala-2.9.1/lib/jline.jar', filter: '!META-INF/MANIFEST.MF' + outjars 'out.jar' + + libraryjars "${System.getProperty('java.home')}/lib/rt.jar" + //libraryjars '/usr/local/java/ant/lib/ant.jar' + //... + + // Ignore some compiler artefacts. + + dontwarn 'scala.**' + + // Save the obfuscation mapping to a file, so you can de-obfuscate any stack + // traces later on. Keep a fixed source file attribute and all line number + // tables to get line numbers in the stack traces. + // You can comment this out if you're not interested in stack traces. + + printmapping 'out.map' + renamesourcefileattribute 'SourceFile' + keepattributes 'SourceFile,LineNumberTable' + + // Preserve all annotations. + + keepattributes '*Annotation*' + + // You can print out the seeds that are matching the keep options below. + + //printseeds 'out.seeds' + + // Preserve all public applications. + + keepclasseswithmembers 'public class * { \ + public static void main(java.lang.String[]); \ + }' + + // Preserve some classes and class members that are accessed by means of + // introspection. + + keep 'class * implements org.xml.sax.EntityResolver' + + keepclassmembers 'class * { \ + ** MODULE$; \ + }' + + keepclassmembernames 'class scala.concurrent.forkjoin.ForkJoinPool { \ + long eventCount; \ + int workerCounts; \ + int runControl; \ + scala.concurrent.forkjoin.ForkJoinPool$WaitQueueNode syncStack; \ + scala.concurrent.forkjoin.ForkJoinPool$WaitQueueNode spareStack; \ + }' + + keepclassmembernames 'class scala.concurrent.forkjoin.ForkJoinWorkerThread { \ + int base; \ + int sp; \ + int runState; \ + }' + + keepclassmembernames 'class scala.concurrent.forkjoin.ForkJoinTask { \ + int status; \ + }' + + keepclassmembernames 'class scala.concurrent.forkjoin.LinkedTransferQueue { \ + scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference head; \ + scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference tail; \ + scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference cleanMe; \ + }' + + // Preserve some classes and class members that are accessed by means of + // introspection in the Scala compiler library, if it is processed as well. + + //keep 'class * implements jline.Completor' + //keep 'class * implements jline.Terminal' + + //keep 'class scala.tools.nsc.Global' + + //keepclasseswithmembers 'class * { \ + // <init>(scala.tools.nsc.Global); \ + //}' + + //keepclassmembers 'class * { \ + // *** scala_repl_value(); \ + // *** scala_repl_result(); \ + //}' + + // Preserve all native method names and the names of their classes. + + keepclasseswithmembernames 'class * { \ + native <methods>; \ + }' + + // Preserve the special static methods that are required in all enumeration + // classes. + + keepclassmembers 'class * extends java.lang.Enum { \ + public static **[] values(); \ + public static ** valueOf(java.lang.String); \ + }' + + // Explicitly preserve all serialization members. The Serializable interface + // is only a marker interface, so it wouldn't save them. + // You can comment this out if your application doesn't use serialization. + // If your code contains serializable classes that have to be backward + // compatible, please refer to the manual. + + keepclassmembers 'class * implements java.io.Serializable { \ + static final long serialVersionUID; \ + static final java.io.ObjectStreamField[] serialPersistentFields; \ + private void writeObject(java.io.ObjectOutputStream); \ + private void readObject(java.io.ObjectInputStream); \ + java.lang.Object writeReplace(); \ + java.lang.Object readResolve(); \ + }' + + // Your application may contain more items that need to be preserved; + // typically classes that are dynamically created using Class.forName: + + // keep 'public class mypackage.MyClass' + // keep 'public interface mypackage.MyInterface' + // keep 'public class * implements mypackage.MyInterface' + +} diff --git a/examples/gradle/servlets.gradle b/examples/gradle/servlets.gradle new file mode 100644 index 0000000..c91ed6a --- /dev/null +++ b/examples/gradle/servlets.gradle @@ -0,0 +1,91 @@ +// +// This Gradle build file illustrates how to process servlets. +// Usage: +// gradle -b servlets.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. + + injars 'in.jar' + outjars 'out.jar' + + libraryjars "${System.getProperty('java.home')}/lib/rt.jar" + libraryjars '/usr/local/java/servlet/servlet.jar' + + // Save the obfuscation mapping to a file, so you can de-obfuscate any stack + // traces later on. Keep a fixed source file attribute and all line number + // tables to get line numbers in the stack traces. + // You can comment this out if you're not interested in stack traces. + + printmapping 'out.map' + renamesourcefileattribute 'SourceFile' + keepattributes 'SourceFile,LineNumberTable' + + // Preserve all annotations. + + keepattributes '*Annotation*' + + // You can print out the seeds that are matching the keep options below. + + //printseeds 'out.seeds' + + // Preserve all public servlets. + + keep 'public class * implements javax.servlet.Servlet' + + // Preserve all native method names and the names of their classes. + + keepclasseswithmembernames 'class * { \ + native <methods>; \ + }' + + // Preserve the special static methods that are required in all enumeration + // classes. + + keepclassmembers 'class * extends java.lang.Enum { \ + public static **[] values(); \ + public static ** valueOf(java.lang.String); \ + }' + + // Explicitly preserve all serialization members. The Serializable interface + // is only a marker interface, so it wouldn't save them. + // You can comment this out if your library doesn't use serialization. + // If your code contains serializable classes that have to be backward + // compatible, please refer to the manual. + + keepclassmembers 'class * implements java.io.Serializable { \ + static final long serialVersionUID; \ + static final java.io.ObjectStreamField[] serialPersistentFields; \ + private void writeObject(java.io.ObjectOutputStream); \ + private void readObject(java.io.ObjectInputStream); \ + java.lang.Object writeReplace(); \ + java.lang.Object readResolve(); \ + }' + + // Your application may contain more items that need to be preserved; + // typically classes that are dynamically created using Class.forName: + + // keep 'public class mypackage.MyClass' + // keep 'public interface mypackage.MyInterface' + // keep 'public class * implements mypackage.MyInterface' +} |