Configuration.java revision db267bc191f906f55eaef21a27110cce2ec57fdf
1/*
2 * ProGuard -- shrinking, optimization, obfuscation, and preverification
3 *             of Java bytecode.
4 *
5 * Copyright (c) 2002-2009 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 */
21package proguard;
22
23import java.io.File;
24import java.util.List;
25
26/**
27 * The ProGuard configuration.
28 *
29 * @see ProGuard
30 *
31 * @author Eric Lafortune
32 */
33public 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     * A list of <code>String</code>s specifying directories to be kept in
63     * the output directories or the output jars. A <code>null</code> list
64     * means no directories. An empty list means all directories. The directory
65     * names may contain "**", "*", or "?" wildcards, and they may be preceded
66     * by the "!" negator.
67     */
68    public List      keepDirectories;
69
70    /**
71     * Specifies the version number of the output classes, or 0 if the version
72     * number can be left unchanged.
73     */
74    public int       targetClassVersion;
75
76    /**
77     * Specifies the last modification time of this configuration. This time
78     * is necessary to check whether the input has to be processed. Setting it
79     * to Long.MAX_VALUE forces processing, even if the modification times
80     * of the output appear more recent than the modification times of the
81     * input.
82     */
83    public long      lastModified                     = 0L;
84
85    ///////////////////////////////////////////////////////////////////////////
86    // Keep options.
87    ///////////////////////////////////////////////////////////////////////////
88
89    /**
90     * A list of {@link KeepClassSpecification} instances, whose class names and
91     * class member names are to be kept from shrinking, optimization, and/or
92     * obfuscation.
93     */
94    public List      keep;
95
96    /**
97     * An optional output file for listing the kept seeds.
98     * An empty file name means the standard output.
99     */
100    public File      printSeeds;
101
102    ///////////////////////////////////////////////////////////////////////////
103    // Shrinking options.
104    ///////////////////////////////////////////////////////////////////////////
105
106    /**
107     * Specifies whether the code should be shrunk.
108     */
109    public boolean   shrink                           = true;
110
111    /**
112     * An optional output file for listing the unused classes and class
113     * members. An empty file name means the standard output.
114     */
115    public File      printUsage;
116
117    /**
118     * A list of {@link ClassSpecification} instances, for which an explanation
119     * is to be printed, why they are kept in the shrinking step.
120     */
121    public List      whyAreYouKeeping;
122
123    ///////////////////////////////////////////////////////////////////////////
124    // Optimization options.
125    ///////////////////////////////////////////////////////////////////////////
126
127    /**
128     * Specifies whether the code should be optimized.
129     */
130    public boolean   optimize                         = true;
131
132    /**
133     * A list of <code>String</code>s specifying the optimizations to be
134     * performed. A <code>null</code> list means all optimizations. The
135     * optimization names may contain "*" or "?" wildcards, and they may
136     * be preceded by the "!" negator.
137     */
138    public List      optimizations;
139
140    /**
141     * Specifies the number of optimization passes.
142     */
143    public int       optimizationPasses               = 1;
144
145    /**
146     * A list of {@link ClassSpecification} instances, whose methods are
147     * assumed to have no side effects.
148     */
149    public List      assumeNoSideEffects;
150
151    /**
152     * Specifies whether the access of class members can be modified.
153     */
154    public boolean   allowAccessModification          = false;
155
156    /**
157     * Specifies whether interfaces may be merged aggressively.
158     */
159    public boolean   mergeInterfacesAggressively      = false;
160
161    ///////////////////////////////////////////////////////////////////////////
162    // Obfuscation options.
163    ///////////////////////////////////////////////////////////////////////////
164
165    /**
166     * Specifies whether the code should be obfuscated.
167     */
168    public boolean   obfuscate                        = true;
169
170    /**
171     * An optional output file for listing the obfuscation mapping.
172     * An empty file name means the standard output.
173     */
174    public File      printMapping;
175
176    /**
177     * An optional input file for reading an obfuscation mapping.
178     */
179    public File      applyMapping;
180
181    /**
182     * An optional name of a file containing obfuscated class member names.
183     */
184    public File      obfuscationDictionary;
185
186    /**
187     * An optional name of a file containing obfuscated class names.
188     */
189    public File      classObfuscationDictionary;
190
191    /**
192     * An optional name of a file containing obfuscated package names.
193     */
194    public File      packageObfuscationDictionary;
195
196    /**
197     * Specifies whether to apply aggressive name overloading on class members.
198     */
199    public boolean   overloadAggressively             = false;
200
201    /**
202     * Specifies whether to generate globally unique class member names.
203     */
204    public boolean   useUniqueClassMemberNames        = false;
205
206    /**
207     * Specifies whether obfuscated packages and classes can get mixed-case names.
208     */
209    public boolean   useMixedCaseClassNames           = true;
210
211    /**
212     * A list of <code>String</code>s specifying package names to be kept.
213     * A <code>null</code> list means no names. An empty list means all
214     * names. The package names may contain "**", "*", or "?" wildcards, and
215     * they may be preceded by the "!" negator.
216     */
217    public List      keepPackageNames;
218
219    /**
220     * An optional base package if the obfuscated package hierarchy is to be
221     * flattened, <code>null</code> otherwise.
222     */
223    public String    flattenPackageHierarchy;
224
225    /**
226     * An optional base package if the obfuscated classes are to be repackaged
227     * into a single package, <code>null</code> otherwise.
228     */
229    public String    repackageClasses;
230
231    /**
232     * A list of <code>String</code>s specifying optional attributes to be kept.
233     * A <code>null</code> list means no attributes. An empty list means all
234     * attributes. The attribute names may contain "*" or "?" wildcards, and
235     * they may be preceded by the "!" negator.
236     */
237    public List      keepAttributes;
238
239    /**
240     * An optional replacement for all SourceFile attributes.
241     */
242    public String    newSourceFileAttribute;
243
244    /**
245     * A list of <code>String</code>s specifying a filter for clases whose
246     * string constants are to be adapted, based on corresponding obfuscated
247     * class names.
248     */
249    public List      adaptClassStrings;
250
251    /**
252     * A list of <code>String</code>s specifying a filter for files whose
253     * names are to be adapted, based on corresponding obfuscated class names.
254     */
255    public List      adaptResourceFileNames;
256
257    /**
258     * A list of <code>String</code>s specifying a filter for files whose
259     * contents are to be adapted, based on obfuscated class names.
260     */
261    public List      adaptResourceFileContents;
262
263    ///////////////////////////////////////////////////////////////////////////
264    // Preverification options.
265    ///////////////////////////////////////////////////////////////////////////
266
267    /**
268     * Specifies whether the code should be preverified.
269     */
270    public boolean   preverify                        = true;
271
272    /**
273     * Specifies whether the code should be preverified for Java Micro Edition
274     * (creating StackMap attributes) instead of for Java Standard Edition
275     * (creating StackMapTable attributes).
276     */
277    public boolean   microEdition                     = false;
278
279    ///////////////////////////////////////////////////////////////////////////
280    // General options.
281    ///////////////////////////////////////////////////////////////////////////
282
283    /**
284     * Specifies whether to print verbose messages.
285     */
286    public boolean   verbose                          = false;
287
288    /**
289     * A list of <code>String</code>s specifying a filter for the classes for
290     * which not to print notes, if there are noteworthy potential problems.
291     * A <code>null</code> list means all classes. The class names may contain
292     * "**", "*", or "?" wildcards, and they may be preceded by the "!" negator.
293     */
294    public List      note                             = null;
295
296    /**
297     * A list of <code>String</code>s specifying a filter for the classes for
298     * which not to print warnings, if there are any problems.
299     * A <code>null</code> list means all classes. The class names may contain
300     * "**", "*", or "?" wildcards, and they may be preceded by the "!" negator.
301     */
302    public List      warn                             = null;
303
304    /**
305     * Specifies whether to ignore any warnings.
306     */
307    public boolean   ignoreWarnings                   = false;
308
309    /**
310     * An optional output file for printing out the configuration that ProGuard
311     * is using (with included files and replaced variables).
312     * An empty file name means the standard output.
313     */
314    public File      printConfiguration;
315
316    /**
317     * An optional output file for printing out the processed code in a more
318     * or less readable form. An empty file name means the standard output.
319     */
320    public File      dump;
321}
322