aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-10-04 13:32:24 -0700
committerXavier Ducrohet <xav@android.com>2011-10-04 13:40:16 -0700
commit6a5504251e5b089d0a41e71fc35f8c7a4bfae635 (patch)
tree08e4852f76ed501931f966d2068a4320e1790adf /sdkmanager
parent581b1e36c0363da17c2568118c08bff040aab920 (diff)
downloadsdk-6a5504251e5b089d0a41e71fc35f8c7a4bfae635.zip
sdk-6a5504251e5b089d0a41e71fc35f8c7a4bfae635.tar.gz
sdk-6a5504251e5b089d0a41e71fc35f8c7a4bfae635.tar.bz2
Make source.prop more important than build.prop when parsing platforms.
Change-Id: I715a7503a7be2b28cd89bd441b8cbb5ee620ccac
Diffstat (limited to 'sdkmanager')
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java197
1 files changed, 98 insertions, 99 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java
index 8b54ccd..6decab0 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java
@@ -344,127 +344,126 @@ public class SdkManager {
private static PlatformTarget loadPlatform(String sdkOsPath, File platformFolder,
ISdkLog log) {
FileWrapper buildProp = new FileWrapper(platformFolder, SdkConstants.FN_BUILD_PROP);
+ FileWrapper sourcePropFile = new FileWrapper(platformFolder, SdkConstants.FN_SOURCE_PROP);
- if (buildProp.isFile()) {
+ if (buildProp.isFile() && sourcePropFile.isFile()) {
+ Map<String, String> platformProp = new HashMap<String, String>();
+
+ // add all the property files
Map<String, String> map = ProjectProperties.parsePropertyFile(buildProp, log);
+ if (map != null) {
+ platformProp.putAll(map);
+ }
+ map = ProjectProperties.parsePropertyFile(sourcePropFile, log);
if (map != null) {
- // look for some specific values in the map.
+ platformProp.putAll(map);
+ }
- // version string
- String apiName = map.get(PROP_VERSION_RELEASE);
- if (apiName == null) {
- log.warning(
- "Ignoring platform '%1$s': %2$s is missing from '%3$s'",
- platformFolder.getName(), PROP_VERSION_RELEASE,
- SdkConstants.FN_BUILD_PROP);
- return null;
+ FileWrapper sdkPropFile = new FileWrapper(platformFolder, SdkConstants.FN_SDK_PROP);
+ if (sdkPropFile.isFile()) { // obsolete platforms don't have this.
+ map = ProjectProperties.parsePropertyFile(sdkPropFile, log);
+ if (map != null) {
+ platformProp.putAll(map);
}
+ }
+
+ // look for some specific values in the map.
- // api level
- int apiNumber;
- String stringValue = map.get(PROP_VERSION_SDK);
- if (stringValue == null) {
+ // api level
+ int apiNumber;
+ String stringValue = platformProp.get(PROP_VERSION_SDK);
+ if (stringValue == null) {
+ log.warning(
+ "Ignoring platform '%1$s': %2$s is missing from '%3$s'",
+ platformFolder.getName(), PROP_VERSION_SDK,
+ SdkConstants.FN_BUILD_PROP);
+ return null;
+ } else {
+ try {
+ apiNumber = Integer.parseInt(stringValue);
+ } catch (NumberFormatException e) {
+ // looks like apiNumber does not parse to a number.
+ // Ignore this platform.
log.warning(
- "Ignoring platform '%1$s': %2$s is missing from '%3$s'",
+ "Ignoring platform '%1$s': %2$s is not a valid number in %3$s.",
platformFolder.getName(), PROP_VERSION_SDK,
SdkConstants.FN_BUILD_PROP);
return null;
- } else {
- try {
- apiNumber = Integer.parseInt(stringValue);
- } catch (NumberFormatException e) {
- // looks like apiNumber does not parse to a number.
- // Ignore this platform.
- log.warning(
- "Ignoring platform '%1$s': %2$s is not a valid number in %3$s.",
- platformFolder.getName(), PROP_VERSION_SDK,
- SdkConstants.FN_BUILD_PROP);
- return null;
- }
}
+ }
- // codename (optional)
- String apiCodename = map.get(PROP_VERSION_CODENAME);
- if (apiCodename != null && apiCodename.equals("REL")) {
- apiCodename = null; // REL means it's a release version and therefore the
- // codename is irrelevant at this point.
- }
-
- // platform rev number & layoutlib version are extracted from the source.properties
- // saved by the SDK Manager when installing the package.
-
- int revision = 1;
- LayoutlibVersion layoutlibVersion = null;
-
- FileWrapper sourcePropFile =
- new FileWrapper(platformFolder, SdkConstants.FN_SOURCE_PROP);
+ // codename (optional)
+ String apiCodename = platformProp.get(PROP_VERSION_CODENAME);
+ if (apiCodename != null && apiCodename.equals("REL")) {
+ apiCodename = null; // REL means it's a release version and therefore the
+ // codename is irrelevant at this point.
+ }
- Map<String, String> sourceProp = ProjectProperties.parsePropertyFile(
- sourcePropFile, log);
+ // version string
+ String apiName = platformProp.get(PkgProps.PLATFORM_VERSION);
+ if (apiName == null) {
+ apiName = platformProp.get(PROP_VERSION_RELEASE);
+ }
+ if (apiName == null) {
+ log.warning(
+ "Ignoring platform '%1$s': %2$s is missing from '%3$s'",
+ platformFolder.getName(), PROP_VERSION_RELEASE,
+ SdkConstants.FN_BUILD_PROP);
+ return null;
+ }
- if (sourceProp != null) {
- try {
- revision = Integer.parseInt(sourceProp.get(PkgProps.PKG_REVISION));
- } catch (NumberFormatException e) {
- // do nothing, we'll keep the default value of 1.
- }
+ // platform rev number & layoutlib version are extracted from the source.properties
+ // saved by the SDK Manager when installing the package.
- try {
- String propApi = sourceProp.get(PkgProps.LAYOUTLIB_API);
- String propRev = sourceProp.get(PkgProps.LAYOUTLIB_REV);
- int llApi = propApi == null ? LayoutlibVersion.NOT_SPECIFIED :
- Integer.parseInt(propApi);
- int llRev = propRev == null ? LayoutlibVersion.NOT_SPECIFIED :
- Integer.parseInt(propRev);
- if (llApi > LayoutlibVersion.NOT_SPECIFIED &&
- llRev >= LayoutlibVersion.NOT_SPECIFIED) {
- layoutlibVersion = new LayoutlibVersion(llApi, llRev);
- }
- } catch (NumberFormatException e) {
- // do nothing, we'll ignore the layoutlib version if it's invalid
- }
+ int revision = 1;
+ LayoutlibVersion layoutlibVersion = null;
+ try {
+ revision = Integer.parseInt(platformProp.get(PkgProps.PKG_REVISION));
+ } catch (NumberFormatException e) {
+ // do nothing, we'll keep the default value of 1.
+ }
- map.putAll(sourceProp);
+ try {
+ String propApi = platformProp.get(PkgProps.LAYOUTLIB_API);
+ String propRev = platformProp.get(PkgProps.LAYOUTLIB_REV);
+ int llApi = propApi == null ? LayoutlibVersion.NOT_SPECIFIED :
+ Integer.parseInt(propApi);
+ int llRev = propRev == null ? LayoutlibVersion.NOT_SPECIFIED :
+ Integer.parseInt(propRev);
+ if (llApi > LayoutlibVersion.NOT_SPECIFIED &&
+ llRev >= LayoutlibVersion.NOT_SPECIFIED) {
+ layoutlibVersion = new LayoutlibVersion(llApi, llRev);
}
+ } catch (NumberFormatException e) {
+ // do nothing, we'll ignore the layoutlib version if it's invalid
+ }
- // Ant properties
- FileWrapper sdkPropFile = new FileWrapper(platformFolder, SdkConstants.FN_SDK_PROP);
- Map<String, String> antProp = null;
- if (sdkPropFile.isFile()) { // obsolete platforms don't have this.
- antProp = ProjectProperties.parsePropertyFile(sdkPropFile, log);
- }
+ // api number and name look valid, perform a few more checks
+ if (checkPlatformContent(platformFolder, log) == false) {
+ return null;
+ }
- if (antProp != null) {
- map.putAll(antProp);
- }
+ ISystemImage[] systemImages =
+ getPlatformSystemImages(sdkOsPath, platformFolder, apiNumber, apiCodename);
+
+ // create the target.
+ PlatformTarget target = new PlatformTarget(
+ sdkOsPath,
+ platformFolder.getAbsolutePath(),
+ apiNumber,
+ apiCodename,
+ apiName,
+ revision,
+ layoutlibVersion,
+ systemImages,
+ platformProp);
- // api number and name look valid, perform a few more checks
- if (checkPlatformContent(platformFolder, log) == false) {
- return null;
- }
+ // need to parse the skins.
+ String[] skins = parseSkinFolder(target.getPath(IAndroidTarget.SKINS));
+ target.setSkins(skins);
- ISystemImage[] systemImages =
- getPlatformSystemImages(sdkOsPath, platformFolder, apiNumber, apiCodename);
-
- // create the target.
- PlatformTarget target = new PlatformTarget(
- sdkOsPath,
- platformFolder.getAbsolutePath(),
- apiNumber,
- apiCodename,
- apiName,
- revision,
- layoutlibVersion,
- systemImages,
- map);
-
- // need to parse the skins.
- String[] skins = parseSkinFolder(target.getPath(IAndroidTarget.SKINS));
- target.setSkins(skins);
-
- return target;
- }
+ return target;
} else {
log.warning("Ignoring platform '%1$s': %2$s is missing.", //$NON-NLS-1$
platformFolder.getName(),