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