From 9093160c8aa3e3832c4db09f57f640055b964bdb Mon Sep 17 00:00:00 2001 From: Raphael Moll Date: Mon, 19 Nov 2012 13:59:43 -0800 Subject: TaskHelper: properly parse Pkg.Revision property. SDK Bug: 36987 Bug was that TaskHelper would fail when parsing a pk revision with an RC value. A quick fix was done in CL 6d266a1bf5992d27fff4400c5d2bd30681c65c3d a while ago. Revisit the fix by using the new FullRevision object to parse the value and create a DeweyDecimal; should avoid us trouble if we later change the format. Change-Id: I5ad1449ebd2606255c27485e60b714b5cf83a308 --- anttasks/src/com/android/ant/TaskHelper.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'anttasks/src/com') diff --git a/anttasks/src/com/android/ant/TaskHelper.java b/anttasks/src/com/android/ant/TaskHelper.java index fe154cf..43ea33a 100644 --- a/anttasks/src/com/android/ant/TaskHelper.java +++ b/anttasks/src/com/android/ant/TaskHelper.java @@ -22,6 +22,8 @@ import com.android.annotations.Nullable; import com.android.sdklib.internal.project.ProjectProperties; import com.android.sdklib.internal.project.ProjectProperties.PropertyType; import com.android.sdklib.internal.project.ProjectPropertiesWorkingCopy; +import com.android.sdklib.internal.repository.packages.FullRevision; +import com.android.sdklib.repository.PkgProps; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; @@ -91,19 +93,17 @@ final class TaskHelper { } } - String value = p.getProperty("Pkg.Revision"); //$NON-NLS-1$ + String value = p.getProperty(PkgProps.PKG_REVISION); if (value != null) { - value = value.trim(); - int space = value.indexOf(' '); - if (space != -1) { - value = value.substring(0, space); - } - return new DeweyDecimal(value); + FullRevision rev = FullRevision.parseRevision(value); + return new DeweyDecimal(rev.toIntArray(false /*includePreview*/)); } + } catch (NumberFormatException e) { + // couldn't parse the version number. } catch (FileNotFoundException e) { - // couldn't find the file? return -1 below. + // couldn't find the file. } catch (IOException e) { - // couldn't find the file? return -1 below. + // couldn't find the file. } return null; -- cgit v1.1