aboutsummaryrefslogtreecommitdiffstats
path: root/files
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-01-17 09:23:34 -0800
committerTor Norbye <tnorbye@google.com>2012-02-21 10:47:08 -0800
commit0bf1b2c94e8b3d829fd69d11f2efd550d6159cb9 (patch)
treeb7026560ed728531c296d549ed8085f27d628be8 /files
parentf9a57e464104e29c045939d84e8d3fb5d9becf7d (diff)
downloadsdk-0bf1b2c94e8b3d829fd69d11f2efd550d6159cb9.zip
sdk-0bf1b2c94e8b3d829fd69d11f2efd550d6159cb9.tar.gz
sdk-0bf1b2c94e8b3d829fd69d11f2efd550d6159cb9.tar.bz2
Split ProGuard file into two halves
This changeset splits the proguard.cfg into two halves: (1) All the general Android settings go into $ANDROID_SDK/proguard/proguard-android.txt. This defines shrinking rules like keep custom views, etc. The crucial point is that this information is maintained and updated by Tools updates, so whenever new APIs are added to Android, or whenever bugs are found in the configuration such as flags needed to work with Dalvik, we can make the updates - we don't have old snapshots living on in projects. (2) Any project specific settings go to proguard-project.txt in the project. (3) The proguard.config property in project.properties now refers to a *path* of configuration files, which are all passed to ProGuard in the given order. The code which processes this setting will substitute android.sdk.home and user.home variables, so the path does not have to be hardcoded to point to the project-android.txt file. The default project templates have been updated to include a commented out configuration setting up proguard as described above. The default proguard file name was changed from proguard.cfg to proguard-project.txt such that it can be directly opened in Eclipse and to make it clear it's an editable text file. Lint was updated to find the Proguard file via the proguard.config property as well as via the old and new default names for projects not enabled with ProGuard. A subsequent CL will add a lint check which identifies projects containing the old setup (full local configuration) and offer to replace it with the new setup. Change-Id: I44b4c97a160114c2382f02f843c95486a0dc9d6b
Diffstat (limited to 'files')
-rw-r--r--files/ant/build.xml13
-rw-r--r--files/proguard-android.txt (renamed from files/proguard.cfg)25
-rw-r--r--files/proguard-project.txt20
3 files changed, 51 insertions, 7 deletions
diff --git a/files/ant/build.xml b/files/ant/build.xml
index 622d558..e47c3fe 100644
--- a/files/ant/build.xml
+++ b/files/ant/build.xml
@@ -766,13 +766,24 @@
</firstmatchmapper>
</pathconvert>
+ <!-- Turn the path property ${proguard.config} from an A:B:C property
+ into a series of includes: -include A -include B -include C
+ suitable for processing by the ProGuard task. Note - this does
+ not include the leading '-include "' or the closing '"'; those
+ are added under the <proguard> call below.
+ -->
+ <path id="proguard.configpath">
+ <pathelement path="${proguard.config}"/>
+ </path>
+ <pathconvert pathsep='" -include "' property="proguard.configcmd" refid="proguard.configpath"/>
+
<mkdir dir="${obfuscate.absolute.dir}" />
<delete file="${preobfuscate.jar.file}"/>
<delete file="${obfuscated.jar.file}"/>
<jar basedir="${out.classes.absolute.dir}"
destfile="${preobfuscate.jar.file}" />
<proguard>
- @${proguard.config}
+ -include "${proguard.configcmd}"
-injars ${project.jars}
-outjars "${obfuscated.jar.file}"
-libraryjars ${android.libraryjars}
diff --git a/files/proguard.cfg b/files/proguard-android.txt
index 53f41fe..b3d2fe1 100644
--- a/files/proguard.cfg
+++ b/files/proguard-android.txt
@@ -1,16 +1,29 @@
--optimizationpasses 5
+# This is a configuration file for ProGuard.
+# http://proguard.sourceforge.net/index.html#manual/usage.html
+
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
--optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
--allowaccessmodification
--keepattributes *Annotation*
-
-# dex does not like code run through proguard optimize and preverify steps.
+# Optimization is turned off by default. Dex does not like code run
+# through the ProGuard optimize and preverify steps (and performs some
+# of these optimizations on its own).
-dontoptimize
-dontpreverify
+# If you want to enable optimization, you should include the
+# following:
+# -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
+# -optimizationpasses 5
+# -allowaccessmodification
+#
+# Note that you cannot just include these flags in your own
+# configuration file; if you are including this file, optimization
+# will be turned off. You'll need to either edit this file, or
+# duplicate the contents of this file and remove the include of this
+# file from your project's proguard.config path property.
+
+-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
diff --git a/files/proguard-project.txt b/files/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/files/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}