Home | History | Annotate | Download | only in ant
      1 <!-- This Ant build file illustrates how to process applications,
      2      using a full-blown XML configuration.
      3      Usage: ant -f applications.xml -->
      4 
      5 <project name="Applications" default="obfuscate" basedir="../..">
      6 
      7 <target name="obfuscate">
      8   <taskdef resource="proguard/ant/task.properties"
      9            classpath="lib/proguard.jar" />
     10 
     11   <proguard printseeds="on">
     12 
     13     <!-- Specify the input jars, output jars, and library jars. -->
     14 
     15     <injar  file="in.jar" />
     16     <outjar file="out.jar" />
     17 
     18     <libraryjar file="${java.home}/lib/rt.jar" />
     19     <!-- libraryjar file="junit.jar"           / -->
     20     <!-- libraryjar file="servlet.jar"         / -->
     21     <!-- libraryjar file="jai_core.jar"        / -->
     22     <!-- ...                                   / -->
     23 
     24 
     25     <!-- Preserve all public applications. -->
     26 
     27     <keepclasseswithmembers access="public">
     28       <method access    ="public static"
     29               type      ="void"
     30               name      ="main"
     31               parameters="java.lang.String[]" />
     32     </keepclasseswithmembers>
     33 
     34     <!-- Preserve all annotations. -->
     35 
     36     <keepattribute name="*Annotation*" />
     37 
     38     <!-- Preserve all native method names and the names of their classes. -->
     39 
     40     <keepclasseswithmembernames>
     41       <method access="native" />
     42     </keepclasseswithmembernames>
     43 
     44     <!-- Preserve the methods that are required in all enumeration classes. -->
     45 
     46     <keepclassmembers extends="java.lang.Enum">
     47       <method access="public static"
     48               type="**[]"
     49               name="values"
     50               parameters="" />
     51       <method access="public static"
     52               type="**"
     53               name="valueOf"
     54               parameters="java.lang.String" />
     55     </keepclassmembers>
     56 
     57     <!-- Explicitly preserve all serialization members. The Serializable
     58          interface is only a marker interface, so it wouldn't save them.
     59          You can comment this out if your library doesn't use serialization.
     60          If your code contains serializable classes that have to be backward
     61          compatible, please refer to the manual. -->
     62 
     63     <keepclassmembers implements="java.io.Serializable">
     64       <field  access    ="static final"
     65               type      ="long"
     66               name      ="serialVersionUID" />
     67       <field  access    ="static final"
     68               type      ="java.io.ObjectStreamField[]"
     69               name      ="serialPersistentFields" />
     70       <method access    ="private"
     71               type      ="void"
     72               name      ="writeObject"
     73               parameters="java.io.ObjectOutputStream" />
     74       <method access    ="private"
     75               type      ="void"
     76               name      ="readObject"
     77               parameters="java.io.ObjectInputStream" />
     78       <method type      ="java.lang.Object"
     79               name      ="writeReplace"
     80               parameters="" />
     81       <method type      ="java.lang.Object"
     82               name      ="readResolve"
     83               parameters="" />
     84     </keepclassmembers>
     85 
     86     <!-- Your application may contain more items that need to be preserved;
     87          typically classes that are dynamically created using Class.forName -->
     88 
     89   </proguard>
     90 </target>
     91 
     92 </project>
     93