1// 2// This Gradle build file illustrates how to process Scala 3// applications, including the Scala runtime. 4// Usage: 5// gradle -b scala.gradle proguard 6// 7 8// Tell Gradle where to find the ProGuard task. 9 10buildscript { 11 repositories { 12 flatDir dirs: '../../lib' 13 } 14 dependencies { 15 classpath ':proguard' 16 } 17} 18 19// Define a ProGuard task. 20 21task proguard(type: proguard.gradle.ProGuardTask) { 22 23 // You should probably import a more compact ProGuard-style configuration 24 // file for all static settings, but we're specifying them all here, for 25 // the sake of the example. 26 //configuration 'configuration.pro' 27 28 // Specify the input jars, output jars, and library jars. 29 30 injars 'in.jar' 31 injars '/usr/local/java/scala-2.9.1/lib/scala-library.jar' 32 //injars '/usr/local/java/scala-2.9.1/lib/scala-compiler.jar', filter: '!META-INF/MANIFEST.MF' 33 //injars '/usr/local/java/scala-2.9.1/lib/jline.jar', filter: '!META-INF/MANIFEST.MF' 34 outjars 'out.jar' 35 36 libraryjars "${System.getProperty('java.home')}/lib/rt.jar" 37 //libraryjars '/usr/local/java/ant/lib/ant.jar' 38 //... 39 40 // Ignore some compiler artefacts. 41 42 dontwarn 'scala.**' 43 44 // Save the obfuscation mapping to a file, so you can de-obfuscate any stack 45 // traces later on. Keep a fixed source file attribute and all line number 46 // tables to get line numbers in the stack traces. 47 // You can comment this out if you're not interested in stack traces. 48 49 printmapping 'out.map' 50 renamesourcefileattribute 'SourceFile' 51 keepattributes 'SourceFile,LineNumberTable' 52 53 // Preserve all annotations. 54 55 keepattributes '*Annotation*' 56 57 // You can print out the seeds that are matching the keep options below. 58 59 //printseeds 'out.seeds' 60 61 // Preserve all public applications. 62 63 keepclasseswithmembers 'public class * { \ 64 public static void main(java.lang.String[]); \ 65 }' 66 67 // Preserve some classes and class members that are accessed by means of 68 // introspection. 69 70 keep 'class * implements org.xml.sax.EntityResolver' 71 72 keepclassmembers 'class * { \ 73 ** MODULE$; \ 74 }' 75 76 keepclassmembernames 'class scala.concurrent.forkjoin.ForkJoinPool { \ 77 long eventCount; \ 78 int workerCounts; \ 79 int runControl; \ 80 scala.concurrent.forkjoin.ForkJoinPool$WaitQueueNode syncStack; \ 81 scala.concurrent.forkjoin.ForkJoinPool$WaitQueueNode spareStack; \ 82 }' 83 84 keepclassmembernames 'class scala.concurrent.forkjoin.ForkJoinWorkerThread { \ 85 int base; \ 86 int sp; \ 87 int runState; \ 88 }' 89 90 keepclassmembernames 'class scala.concurrent.forkjoin.ForkJoinTask { \ 91 int status; \ 92 }' 93 94 keepclassmembernames 'class scala.concurrent.forkjoin.LinkedTransferQueue { \ 95 scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference head; \ 96 scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference tail; \ 97 scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference cleanMe; \ 98 }' 99 100 // Preserve some classes and class members that are accessed by means of 101 // introspection in the Scala compiler library, if it is processed as well. 102 103 //keep 'class * implements jline.Completor' 104 //keep 'class * implements jline.Terminal' 105 106 //keep 'class scala.tools.nsc.Global' 107 108 //keepclasseswithmembers 'class * { \ 109 // <init>(scala.tools.nsc.Global); \ 110 //}' 111 112 //keepclassmembers 'class * { \ 113 // *** scala_repl_value(); \ 114 // *** scala_repl_result(); \ 115 //}' 116 117 // Preserve all native method names and the names of their classes. 118 119 keepclasseswithmembernames includedescriptorclasses:true, 'class * { \ 120 native <methods>; \ 121 }' 122 123 // Preserve the special static methods that are required in all enumeration 124 // classes. 125 126 keepclassmembers allowshrinking:true, 'enum * { \ 127 public static **[] values(); \ 128 public static ** valueOf(java.lang.String); \ 129 }' 130 131 // Explicitly preserve all serialization members. The Serializable interface 132 // is only a marker interface, so it wouldn't save them. 133 // You can comment this out if your application doesn't use serialization. 134 // If your code contains serializable classes that have to be backward 135 // compatible, please refer to the manual. 136 137 keepclassmembers 'class * implements java.io.Serializable { \ 138 static final long serialVersionUID; \ 139 static final java.io.ObjectStreamField[] serialPersistentFields; \ 140 private void writeObject(java.io.ObjectOutputStream); \ 141 private void readObject(java.io.ObjectInputStream); \ 142 java.lang.Object writeReplace(); \ 143 java.lang.Object readResolve(); \ 144 }' 145 146 // Your application may contain more items that need to be preserved; 147 // typically classes that are dynamically created using Class.forName: 148 149 // keep 'public class mypackage.MyClass' 150 // keep 'public interface mypackage.MyInterface' 151 // keep 'public class * implements mypackage.MyInterface' 152 153} 154