diff options
author | Tor Norbye <tnorbye@google.com> | 2012-01-17 09:23:34 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-02-21 10:47:08 -0800 |
commit | 0bf1b2c94e8b3d829fd69d11f2efd550d6159cb9 (patch) | |
tree | b7026560ed728531c296d549ed8085f27d628be8 /sdkmanager/libs/sdklib | |
parent | f9a57e464104e29c045939d84e8d3fb5d9becf7d (diff) | |
download | sdk-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 'sdkmanager/libs/sdklib')
3 files changed, 25 insertions, 10 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java index 4f3ed9f..e21e14f 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java @@ -166,8 +166,10 @@ public final class SdkConstants { */ public final static String FN_GDBSERVER = "gdbserver"; //$NON-NLS-1$ - /** default proguard config file */ - public final static String FN_PROGUARD_CFG = "proguard.cfg"; //$NON-NLS-1$ + /** global Android proguard config file */ + public final static String FN_ANDROID_PROGUARD_FILE = "proguard-android.txt"; //$NON-NLS-1$ + /** default proguard config file with new file extension (for project specific stuff) */ + public final static String FN_PROJECT_PROGUARD_FILE = "proguard-project.txt"; //$NON-NLS-1$ /* Folder Names for Android Projects . */ @@ -385,7 +387,6 @@ public final class SdkConstants { /** SDK property: default skin */ public final static String PROP_SDK_DEFAULT_SKIN = "sdk.skin.default"; //$NON-NLS-1$ - /* Android Class Constants */ public final static String CLASS_ACTIVITY = "android.app.Activity"; //$NON-NLS-1$ public final static String CLASS_APPLICATION = "android.app.Application"; //$NON-NLS-1$ diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java index c3d7993..721d165 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java @@ -369,8 +369,8 @@ public class ProjectCreator { keywords); // install the proguard config file. - installTemplate(SdkConstants.FN_PROGUARD_CFG, - new File(projectFolder, SdkConstants.FN_PROGUARD_CFG), + installTemplate(SdkConstants.FN_PROJECT_PROGUARD_FILE, + new File(projectFolder, SdkConstants.FN_PROJECT_PROGUARD_FILE), null /*keywords*/); } catch (Exception e) { mLog.error(e, null); @@ -751,8 +751,10 @@ public class ProjectCreator { if (hasProguard == false) { try { - installTemplate(SdkConstants.FN_PROGUARD_CFG, - new File(projectFolder, SdkConstants.FN_PROGUARD_CFG), + installTemplate(SdkConstants.FN_PROJECT_PROGUARD_FILE, + // Write ProGuard config files with the extension .pro which + // is what is used in the ProGuard documentation and samples + new File(projectFolder, SdkConstants.FN_PROJECT_PROGUARD_FILE), null /*placeholderMap*/); } catch (ProjectCreateException e) { mLog.error(e, null); diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java index 3a73bef..2bb6b71 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java @@ -16,6 +16,11 @@ package com.android.sdklib.internal.project; +import static com.android.sdklib.SdkConstants.FD_PROGUARD; +import static com.android.sdklib.SdkConstants.FD_TOOLS; +import static com.android.sdklib.SdkConstants.FN_ANDROID_PROGUARD_FILE; +import static com.android.sdklib.SdkConstants.FN_PROJECT_PROGUARD_FILE; + import com.android.io.FolderWrapper; import com.android.io.IAbstractFile; import com.android.io.IAbstractFolder; @@ -24,6 +29,7 @@ import com.android.sdklib.ISdkLog; import com.android.sdklib.SdkConstants; import java.io.BufferedReader; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; @@ -163,7 +169,7 @@ public class ProjectProperties { "# This file is automatically generated by Android Tools.\n" + "# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n" + "#\n" + - "# This file must *NOT* be checked in Version Control Systems,\n" + + "# This file must *NOT* be checked into Version Control Systems,\n" + "# as it contains information specific to your local configuration.\n" + "\n"; @@ -174,16 +180,22 @@ public class ProjectProperties { "#\n" + "# This file must be checked in Version Control Systems.\n" + "#\n" + - "# To customize properties used by the Ant build system use,\n" + + "# To customize properties used by the Ant build system edit\n" + "# \"ant.properties\", and override values to adapt the script to your\n" + "# project structure.\n" + + "#\n" + + "# To enable ProGuard to shrink and obfuscate your code, uncomment this " + + "(available properties: sdk.dir, user.home):\n" + + "#" + PROPERTY_PROGUARD_CONFIG + "=${" + PROPERTY_SDK +"}" + File.separator + + FD_TOOLS + File.separator + FD_PROGUARD + File.separator + + FN_ANDROID_PROGUARD_FILE + ':' + FN_PROJECT_PROGUARD_FILE +'\n' + "\n"; private final static String BUILD_HEADER = // 1-------10--------20--------30--------40--------50--------60--------70--------80 "# This file is used to override default values used by the Ant build system.\n" + "#\n" + - "# This file must be checked in Version Control Systems, as it is\n" + + "# This file must be checked into Version Control Systems, as it is\n" + "# integral to the build system of your project.\n" + "\n" + "# This file is only used by the Ant script.\n" + |