KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > proguard > Configuration


1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  * of Java bytecode.
4  *
5  * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21 package proguard;
22
23 import java.io.File JavaDoc;
24 import java.util.List JavaDoc;
25
26 /**
27  * The ProGuard configuration.
28  *
29  * @see ProGuard
30  *
31  * @author Eric Lafortune
32  */

33 public class Configuration
34 {
35     ///////////////////////////////////////////////////////////////////////////
36
// Input and output options.
37
///////////////////////////////////////////////////////////////////////////
38

39     /**
40      * A list of input and output entries (jars, wars, ears, zips, and directories).
41      */

42     public ClassPath programJars;
43
44     /**
45      * A list of library entries (jars, wars, ears, zips, and directories).
46      */

47     public ClassPath libraryJars;
48
49     /**
50      * Specifies whether to skip non-public library classes while reading
51      * library jars.
52      */

53     public boolean skipNonPublicLibraryClasses = true;
54
55     /**
56      * Specifies whether to skip non-public library class members while reading
57      * library classes.
58      */

59     public boolean skipNonPublicLibraryClassMembers = true;
60
61     /**
62      * Specifies the version number of the output classes, or 0 if the version
63      * number can be left unchanged.
64      */

65     public int targetClassVersion;
66
67     /**
68      * Specifies the last modification time of this configuration. This time
69      * is necessary to check whether the input has to be processed. Setting it
70      * to Long.MAX_VALUE forces processing, even if the modification times
71      * of the output appear more recent than the modification times of the
72      * input.
73      */

74     public long lastModified = 0L;
75
76     ///////////////////////////////////////////////////////////////////////////
77
// Keep options.
78
///////////////////////////////////////////////////////////////////////////
79

80     /**
81      * A list of {@link KeepSpecification} instances, whose class names and
82      * class member names are to be kept from shrinking, optimization, and/or
83      * obfuscation.
84      */

85     public List JavaDoc keep;
86
87     /**
88      * An optional output file for listing the kept seeds.
89      * An empty file name means the standard output.
90      */

91     public File JavaDoc printSeeds;
92
93     ///////////////////////////////////////////////////////////////////////////
94
// Shrinking options.
95
///////////////////////////////////////////////////////////////////////////
96

97     /**
98      * Specifies whether the code should be shrunk.
99      */

100     public boolean shrink = true;
101
102     /**
103      * An optional output file for listing the unused classes and class
104      * members. An empty file name means the standard output.
105      */

106     public File JavaDoc printUsage;
107
108     /**
109      * A list of {@link ClassSpecification} instances, for which an explanation
110      * is to be printed, why they are kept in the shrinking step.
111      */

112     public List JavaDoc whyAreYouKeeping;
113
114     ///////////////////////////////////////////////////////////////////////////
115
// Optimization options.
116
///////////////////////////////////////////////////////////////////////////
117

118     /**
119      * Specifies whether the code should be optimized.
120      */

121     public boolean optimize = true;
122
123     /**
124      * Specifies the number of optimization passes.
125      */

126     public int optimizationPasses = 1;
127
128     /**
129      * A list of {@link ClassSpecification} instances, whose methods are
130      * assumed to have no side effects.
131      */

132     public List JavaDoc assumeNoSideEffects;
133
134     /**
135      * Specifies whether the access of class members can be modified.
136      */

137     public boolean allowAccessModification = false;
138
139     ///////////////////////////////////////////////////////////////////////////
140
// Obfuscation options.
141
///////////////////////////////////////////////////////////////////////////
142

143     /**
144      * Specifies whether the code should be obfuscated.
145      */

146     public boolean obfuscate = true;
147
148     /**
149      * An optional output file for listing the obfuscation mapping.
150      * An empty file name means the standard output.
151      */

152     public File JavaDoc printMapping;
153
154     /**
155      * An optional input file for reading an obfuscation mapping.
156      */

157     public File JavaDoc applyMapping;
158
159     /**
160      * An optional name of a file containing obfuscated class member names.
161      */

162     public File JavaDoc obfuscationDictionary;
163
164     /**
165      * Specifies whether to apply aggressive name overloading on class members.
166      */

167     public boolean overloadAggressively = false;
168
169     /**
170      * Specifies whether to generate globally unique class member names.
171      */

172     public boolean useUniqueClassMemberNames = false;
173
174     /**
175      * Specifies whether obfuscated packages and classes can get mixed-case names.
176      */

177     public boolean useMixedCaseClassNames = true;
178
179     /**
180      * An optional base package if the obfuscated package hierarchy is to be
181      * flattened, <code>null</code> otherwise.
182      */

183     public String JavaDoc flattenPackageHierarchy;
184
185     /**
186      * An optional base package if the obfuscated classes are to be repackaged
187      * into a single package, <code>null</code> otherwise.
188      */

189     public String JavaDoc repackageClasses;
190
191     /**
192      * A list of <code>String</code>s specifying optional attributes to be kept.
193      * A <code>null</code> list means no attributes. An empty list means all
194      * attributes. The attribute names may contain "*" or "?" wildcards, and
195      * they may be preceded by the "!" negator.
196      */

197     public List JavaDoc keepAttributes;
198
199     /**
200      * An optional replacement for all SourceFile attributes.
201      */

202     public String JavaDoc newSourceFileAttribute;
203
204     /**
205      * A list of <code>String</code>s specifying a filter for files whose
206      * names are to be adapted, based on corresponding obfuscated class names.
207      */

208     public List JavaDoc adaptResourceFileNames;
209
210     /**
211      * A list of <code>String</code>s specifying a filter for files whose
212      * contents are to be adapted, based on obfuscated class names.
213      */

214     public List JavaDoc adaptResourceFileContents;
215
216     ///////////////////////////////////////////////////////////////////////////
217
// Preverification options.
218
///////////////////////////////////////////////////////////////////////////
219

220     /**
221      * Specifies whether the code should be preverified.
222      */

223     public boolean preverify = true;
224
225     /**
226      * Specifies whether the code should be preverified for Java Micro Edition
227      * (creating StackMap attributes) instead of for Java Standard Edition
228      * (creating StackMapTable attributes).
229      */

230     public boolean microEdition = false;
231
232     ///////////////////////////////////////////////////////////////////////////
233
// General options.
234
///////////////////////////////////////////////////////////////////////////
235

236     /**
237      * Specifies whether to print verbose messages.
238      */

239     public boolean verbose = false;
240
241     /**
242      * Specifies whether to print any notes.
243      */

244     public boolean note = true;
245
246     /**
247      * Specifies whether to print any warnings.
248      */

249     public boolean warn = true;
250
251     /**
252      * Specifies whether to ignore any warnings.
253      */

254     public boolean ignoreWarnings = false;
255
256     /**
257      * An optional output file for printing out the configuration that ProGuard
258      * is using (with included files and replaced variables).
259      * An empty file name means the standard output.
260      */

261     public File JavaDoc printConfiguration;
262
263     /**
264      * An optional output file for printing out the processed code in a more
265      * or less readable form. An empty file name means the standard output.
266      */

267     public File JavaDoc dump;
268 }
269
Popular Tags