Permalink
Browse files

split proguard-base as a single library

  • Loading branch information...
1 parent 77f6263 commit 7ed892d9c4b1058aef1268d7d8a6f107422322b8 @achellies committed Nov 3, 2016
Showing 1,216 changed files with 112,891 additions and 103,426 deletions.
View
@@ -4,7 +4,12 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.0'
+ classpath ('com.android.tools.build:gradle:2.2.0') {
+ exclude module: 'proguard-base'
+ }
+ classpath ('net.sf.proguard:proguard-base:5.3.9') {
+ force = true
+ }
}
}
View
@@ -16,7 +16,7 @@ dependencies {
compile 'com.android.tools.build:gradle:2.2.0'
compile 'org.ow2.asm:asm:5.0'
compile 'org.javassist:javassist:3.20.0-GA'
- compile 'net.sf.proguard:proguard-base:5.3.1'
+ compile 'net.sf.proguard:proguard-base:5.3.9'
compile fileTree(dir: "./src/main/libs", include: ['*.jar'])
}
@@ -1,17 +1,9 @@
package com.achellies.gradle.ultron
-import com.android.SdkConstants
import com.android.build.gradle.api.BaseVariant
import com.android.build.gradle.internal.pipeline.TransformTask
import com.android.build.gradle.internal.transforms.ProGuardTransform
import com.android.utils.XmlUtils
-import javassist.CannotCompileException
-import javassist.ClassPool
-import javassist.CtClass
-import javassist.CtMethod
-import javassist.expr.ExprEditor
-import javassist.expr.MethodCall
-import org.apache.commons.io.IOUtils
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.tooling.BuildException
@@ -20,21 +12,13 @@ import org.w3c.dom.Element
import org.w3c.dom.Node
import org.w3c.dom.NodeList
import org.xml.sax.SAXException
-import proguard.ProGuard
-import proguard.obfuscate.MemberNameCollector
-import proguard.obfuscate.MemberNameConflictFixer
-import proguard.obfuscate.MemberObfuscator
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.Transformer
import javax.xml.transform.TransformerFactory
import javax.xml.transform.dom.DOMSource
import javax.xml.transform.stream.StreamResult
-import java.util.jar.JarEntry
-import java.util.jar.JarFile
-import java.util.jar.JarOutputStream
-import java.util.zip.ZipEntry
import static com.android.SdkConstants.ATTR_PACKAGE
import static com.android.SdkConstants.TAG_APPLICATION
@@ -63,11 +47,6 @@ class UltronPlugin implements Plugin<Project> {
}
}
- new ProGuard(null);
- new MemberObfuscator(false, null, null);
- new MemberNameCollector(false, null);
- new MemberNameConflictFixer(false, null, null, null);
-
applyExtension(project);
UltronPlugin plugin = this;
@@ -82,70 +61,6 @@ class UltronPlugin implements Plugin<Project> {
}
- String trickDxJarForRuntimeVisibleAnnotations(String jarPath) {
-
- def dxJarFile = new File(jarPath)
- def jar = new JarFile(dxJarFile)
-
- def trickedJar = new File(dxJarFile.parentFile, "${dxJarFile.name}_bat.jar")
- if (!trickedJar.exists()) {
-
- JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(trickedJar));
-
- Enumeration enumeration = jar.entries();
- while (enumeration.hasMoreElements()) {
- JarEntry jarEntry = (JarEntry) enumeration.nextElement();
-
- String entryName = jarEntry.name;
-
- ZipEntry zipEntry = new ZipEntry(entryName);
-
- InputStream inputStream = jar.getInputStream(jarEntry);
-
- if (entryName.endsWith(SdkConstants.DOT_CLASS) && (entryName.startsWith("proguard"))) {
-// try {
-// def classPool = new ClassPool(null)
-// classPool.appendSystemPath()
-// classPool.appendClassPath(dxJarFile.absolutePath)
-//
-// CtClass ctClass = classPool.getOrNull("proguard.classfile.ClassPool")
-// if (ctClass != null) {
-// CtMethod ctMethod = ctClass.getDeclaredMethod("parseClass")
-// ctMethod.instrument(new ExprEditor() {
-// @Override
-// void edit(MethodCall m) throws CannotCompileException {
-// super.edit(m)
-// if (m.methodName.contentEquals("getMagic") && m.className.contentEquals("com.android.dx.cf.direct.DirectClassFile")) {
-// m.replace("if (\$0.getMajorVersion0() >= 52) {\n" +
-// "com.android.dx.command.DxConsole.err.println(name);};\n" +
-// "\$_ = \$proceed(\$\$);")
-// }
-// }
-// })
-// }
-//
-// jarOutputStream.putNextEntry(zipEntry);
-// jarOutputStream.write(ctClass.toBytecode())
-// ctClass.detach()
-// } catch (Exception e) {
- jarOutputStream.putNextEntry(zipEntry);
- jarOutputStream.write(IOUtils.toByteArray(inputStream));
-// }
- }
-// else {
-// jarOutputStream.putNextEntry(zipEntry);
-// jarOutputStream.write(IOUtils.toByteArray(inputStream));
-// }
- inputStream.close()
- jarOutputStream.closeEntry();
- }
-
- jarOutputStream.close();
- }
-
- return trickedJar.absolutePath
- }
-
void configUltronTask(UltronPlugin plugin) {
for (BaseVariant variant : GradleUtils.getAndroidVariants(project)) {
def variantName = variant.name.capitalize()
@@ -157,7 +72,7 @@ class UltronPlugin implements Plugin<Project> {
configureProguard(variant, proguard, pt)
proguard.doFirst {
- applyProGuardMapping(project);
+ applyProGuardMapping(project, pt);
// println "applyMapping = " + pt.configuration.applyMapping;
// println "testedMappingFile = " + pt.testedMappingFile;
@@ -194,10 +109,10 @@ class UltronPlugin implements Plugin<Project> {
// pt.keep("interface com.android.tools.fd.runtime.IncrementalChange { *; }");
// pt.keep("class * implements com.android.tools.fd.runtime.IncrementalChange { *; }");
// pt.keep("class com.android.tools.fd.** {*;}");
- applyProGuardMapping(project);
+ applyProGuardMapping(project, pt);
}
- void applyProGuardMapping(Project project) {
+ void applyProGuardMapping(Project project, ProGuardTransform pt) {
UltronExtension extension = getConfig(project);
if (extension.applyProGuardMappingFilePath != null && !extension.applyProGuardMappingFilePath.isEmpty()) {
def mappingFile = new File(extension.applyProGuardMappingFilePath);
@@ -1,99 +0,0 @@
-/*
- * ProGuard -- shrinking, optimization, obfuscation, and preverification
- * of Java bytecode.
- *
- * Copyright (c) 2002-2015 Eric Lafortune @ GuardSquare
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-package proguard;
-
-import java.io.*;
-
-
-/**
- * A <code>WordReader</code> that returns words from an argument list.
- * Single arguments are split into individual words if necessary.
- *
- * @author Eric Lafortune
- */
-public class ArgumentWordReader extends WordReader {
- private final String[] arguments;
-
- private int index = 0;
-
-
-// /**
-// * Creates a new ArgumentWordReader for the given arguments.
-// */
-// public ArgumentWordReader(String[] arguments)
-// {
-// this(arguments, null);
-// }
-//
-//
-
- /**
- * Creates a new ArgumentWordReader for the given arguments, with the
- * given base directory.
- */
- public ArgumentWordReader(String[] arguments, File baseDir) {
- super(baseDir);
-
- this.arguments = arguments;
- }
-
-
- // Implementations for WordReader.
-
- protected String nextLine() throws IOException {
- return index < arguments.length ?
- arguments[index++] :
- null;
- }
-
-
- protected String lineLocationDescription() {
- return "argument number " + index;
- }
-
-
- /**
- * Test application that prints out the individual words of
- * the argument list.
- */
- public static void main(String[] args) {
-
- try {
- WordReader reader = new ArgumentWordReader(args, null);
-
- try {
- while (true) {
- String word = reader.nextWord(false);
- if (word == null)
- System.exit(-1);
-
- System.err.println("[" + word + "]");
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- } finally {
- reader.close();
- }
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
-}
@@ -1,88 +0,0 @@
-/*
- * ProGuard -- shrinking, optimization, obfuscation, and preverification
- * of Java bytecode.
- *
- * Copyright (c) 2002-2015 Eric Lafortune @ GuardSquare
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-package proguard;
-
-import proguard.classfile.util.*;
-
-import java.util.List;
-
-/**
- * This class checks if the user is specifying to assume no side effects
- * for a reasonable number of methods in a class: not none and not all.
- *
- * @author Eric Lafortune
- */
-public class AssumeNoSideEffectsChecker {
- private final WarningPrinter notePrinter;
-
-
- /**
- * Creates a new KeepClassMemberChecker.
- */
- public AssumeNoSideEffectsChecker(WarningPrinter notePrinter) {
- this.notePrinter = notePrinter;
- }
-
-
- /**
- * Checks if the given class specifications try to assume no side effects
- * for all methods in a class, printing notes if necessary.
- */
- public void checkClassSpecifications(List classSpecifications) {
- if (classSpecifications != null) {
- for (int classSpecificationIndex = 0;
- classSpecificationIndex < classSpecifications.size();
- classSpecificationIndex++) {
- ClassSpecification classSpecification =
- (ClassSpecification) classSpecifications.get(classSpecificationIndex);
-
- String className = classSpecification.className;
- if (className == null) {
- className = classSpecification.extendsClassName;
- }
-
- if (className == null ||
- notePrinter.accepts(className)) {
- List methodSpecifications =
- classSpecification.methodSpecifications;
-
- if (methodSpecifications != null) {
- for (int methodSpecificationIndex = 0;
- methodSpecificationIndex < methodSpecifications.size();
- methodSpecificationIndex++) {
- final MemberSpecification methodSpecification =
- (MemberSpecification) methodSpecifications.get(methodSpecificationIndex);
-
- if (methodSpecification.name == null &&
- methodSpecification.descriptor == null) {
- notePrinter.print(className,
- "Note: the configuration specifies that none of the methods of class '" +
- (className == null ?
- ConfigurationConstants.ANY_CLASS_KEYWORD :
- ClassUtil.externalClassName(className)) + "' have any side effects");
- }
- }
- }
- }
- }
- }
- }
-}
Oops, something went wrong.

0 comments on commit 7ed892d

Please sign in to comment.