use of proguard.Configuration in project atlas by alibaba.
the class BundleProguarder method parseConfiguration.
@NotNull
private static Configuration parseConfiguration(AppVariantContext appVariantContext, Input input) throws IOException, ParseException {
Configuration configuration = new Configuration();
List<File> proguardFiles = new ArrayList<>();
proguardFiles.add(printInOut(appVariantContext, input));
proguardFiles.addAll(input.getDefaultProguardFiles());
proguardFiles.addAll(input.getParentKeeps());
for (File file : proguardFiles) {
ConfigurationParser parser = new ConfigurationParser(file, System.getProperties());
try {
parser.parse(configuration);
} finally {
parser.close();
}
}
for (File file : input.getLibraryProguardFiles()) {
KeepOnlyConfigurationParser parser = new KeepOnlyConfigurationParser(file, System.getProperties());
try {
parser.parse(configuration);
} finally {
parser.close();
}
}
return configuration;
}
use of proguard.Configuration in project atlas by alibaba.
the class BundleProguarder method doProguard.
public static void doProguard(AppVariantContext appVariantContext, Input input) throws Exception {
Configuration configuration = parseConfiguration(appVariantContext, input);
configuration.dump = input.dump;
if (null == input.printConfiguration) {
configuration.printConfiguration = new File(appVariantContext.getAwbProguardDir(input.getAwbBundles().get(0).getAwbBundle()), "proguard.cfg");
} else {
configuration.printConfiguration = input.printConfiguration;
}
configuration.printSeeds = null;
configuration.dump = null;
configuration.obfuscate = false;
// configuration.optimizationPasses = 1;
configuration.printUsage = input.printUsage;
configuration.printMapping = input.printMapping;
// Execute ProGuard with these options.
ProGuard proGuard = new ProGuard(configuration);
System.out.println(">>> start to do proguard");
proGuard.execute();
System.out.println("<<< end proguard");
ClassPool classPool = (ClassPool) ReflectUtils.getField(proGuard, "programClassPool");
Map<String, ClazzRefInfo> clazzRefInfoMap = BundleProguardDumper.dump(proGuard, input.getDefaultLibraryClasses());
// Fileoutputs
for (AwbTransform awbTransform : input.getAwbBundles()) {
if (!awbTransform.getAwbBundle().isMainBundle()) {
AwbBundle awbBundle = awbTransform.getAwbBundle();
File fileOut = new File(appVariantContext.getAwbProguardDir(awbBundle), "keep.json");
fileOut.delete();
fileOut.getParentFile().mkdirs();
FileUtils.write(fileOut, JSON.toJSONString(clazzRefInfoMap));
awbBundle.setKeepProguardFile(fileOut);
}
}
}
Aggregations