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