From 5b13066ef1b430ceba97564b7a63a8d56406dbb3 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Wed, 12 Aug 2009 17:48:32 -0700 Subject: [PATCH] On project creation, put the app package in build.properties This enabled 'ant uninstall' to work. Also, add an error message to the uninstall rules in case the property is not defined. BUG: 2050451 --- tools/scripts/android_rules.xml | 10 +++++++++- .../sdklib/internal/project/ProjectCreator.java | 3 ++- .../internal/project/ProjectProperties.java | 17 +++++++---------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/scripts/android_rules.xml b/tools/scripts/android_rules.xml index 1f5daac83..be532643e 100644 --- a/tools/scripts/android_rules.xml +++ b/tools/scripts/android_rules.xml @@ -201,7 +201,15 @@ - + + + + + + + Unable to run 'ant unintall', application-package is not defined in build.properties + + Uninstalling ${application-package} from the default emulator... diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java index 1e16a8365..916fa7c40 100644 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java @@ -199,9 +199,10 @@ public class ProjectCreator { defaultProperties.setAndroidTarget(target); defaultProperties.save(); - // create an empty build.properties + // create a build.properties file with just the application package ProjectProperties buildProperties = ProjectProperties.create(folderPath, PropertyType.BUILD); + buildProperties.setProperty(ProjectProperties.PROPERTY_APP_PACKAGE, packageName); buildProperties.save(); // create the map for place-holders of values to replace in the templates diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java index 33f88372a..d71491c72 100644 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java @@ -22,7 +22,6 @@ import com.android.sdklib.SdkManager; import java.io.File; import java.io.FileOutputStream; -import java.io.FileWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.HashMap; @@ -38,6 +37,7 @@ public final class ProjectProperties { public final static String PROPERTY_TARGET = "target"; public final static String PROPERTY_APK_CONFIGS = "apk-configurations"; public final static String PROPERTY_SDK = "sdk-location"; + public final static String PROPERTY_APP_PACKAGE = "application-package"; public static enum PropertyType { BUILD("build.properties", BUILD_HEADER), @@ -85,15 +85,9 @@ public final class ProjectProperties { "# This file must be checked in Version Control Systems, as it is\n" + "# integral to the build system of your project.\n" + "\n" + - "# The name of your application package as defined in the manifest.\n" + - "# Used by the 'uninstall' rule.\n"+ - "#application-package=com.example.myproject\n" + - "\n" + - "# The name of the source folder.\n" + - "#source-folder=src\n" + - "\n" + - "# The name of the output folder.\n" + - "#out-folder=bin\n" + + "# You can use this to override default values such as\n" + + "# 'source-folder' for the location of your java source folder and\n" + + "# 'out-folder' for the location of your output folder.\n" + "\n"; private final static Map COMMENT_MAP = new HashMap(); @@ -116,6 +110,9 @@ public final class ProjectProperties { "# location of the SDK. This is only used by Ant\n" + "# For customization when using a Version Control System, please read the\n" + "# header note.\n"); + COMMENT_MAP.put(PROPERTY_APP_PACKAGE, + "# The name of your application package as defined in the manifest.\n" + + "# Used by the 'uninstall' rule.\n"); } private final String mProjectFolderOsPath;