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