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