From 249dc0127b12679441013dd78208706feb632c59 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Fri, 25 May 2012 16:27:34 -0700 Subject: Use aapt output to feed proguard's keep list. This allows us to only keep classes that are really used either through code or through XML. Also tweak the default rules for better control of animated properties. Added a test of a custom property animation and fixed some other misc test files. Change-Id: I7cc5839a764881d8d3c7bfce0a3f12ea7cba660e --- anttasks/src/com/android/ant/AaptExecTask.java | 38 ++++++++++++-------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'anttasks') diff --git a/anttasks/src/com/android/ant/AaptExecTask.java b/anttasks/src/com/android/ant/AaptExecTask.java index 2b57277..c96f7d0 100644 --- a/anttasks/src/com/android/ant/AaptExecTask.java +++ b/anttasks/src/com/android/ant/AaptExecTask.java @@ -97,6 +97,7 @@ public final class AaptExecTask extends SingleDependencyTask { private String mLibraryPackagesRefid; private boolean mNonConstantId; private String mIgnoreAssets; + private String mProguardFile; /** * Input path that ignores the same folders/files that aapt does. @@ -321,6 +322,10 @@ public final class AaptExecTask extends SingleDependencyTask { mLibraryPackagesRefid = libraryPackagesRefid; } + public void setProguardFile(Path proguardFile) { + mProguardFile = TaskHelper.checkSinglePath("proguardFile", proguardFile); + } + /** * Returns an object representing a nested nocompress element. */ @@ -344,6 +349,11 @@ public final class AaptExecTask extends SingleDependencyTask { return path; } + @Override + protected String getExecTaskName() { + return "aapt"; + } + /* * (non-Javadoc) * @@ -375,24 +385,6 @@ public final class AaptExecTask extends SingleDependencyTask { libPkgProp = libPkgProp.replace(';', ':'); } } - // Call aapt. If there are libraries, we'll pass a non-null string of libs. - callAapt(libPkgProp); - } - - @Override - protected String getExecTaskName() { - return "aapt"; - } - - /** - * Calls aapt with the given parameters. - * @param resourceFilter the resource configuration filter to pass to aapt (if configName is - * non null) - * @param extraPackages an optional list of colon-separated packages. Can be null - * Ex: com.foo.one:com.foo.two:com.foo.lib - */ - private void callAapt(String extraPackages) { - Project taskProject = getProject(); final boolean generateRClass = mRFolder != null && new File(mRFolder).isDirectory(); @@ -538,9 +530,9 @@ public final class AaptExecTask extends SingleDependencyTask { } } - if (mNonConstantId == false && extraPackages != null && extraPackages.length() > 0) { + if (mNonConstantId == false && libPkgProp != null && libPkgProp.length() > 0) { task.createArg().setValue("--extra-packages"); - task.createArg().setValue(extraPackages); + task.createArg().setValue(libPkgProp); } // if the project contains libraries, force auto-add-overlay @@ -635,6 +627,12 @@ public final class AaptExecTask extends SingleDependencyTask { // Use dependency generation task.createArg().setValue("--generate-dependencies"); + // use the proguard file + if (mProguardFile != null && mProguardFile.length() > 0) { + task.createArg().setValue("-G"); + task.createArg().setValue(mProguardFile); + } + // final setup of the task task.setProject(taskProject); task.setOwningTarget(getOwningTarget()); -- cgit v1.1