diff options
author | Xavier Ducrohet <xav@android.com> | 2012-07-09 12:22:13 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2012-07-09 12:22:13 -0700 |
commit | ac7efd7e9f6f9a9fd76afaa774f26ad76602c25a (patch) | |
tree | d09121f81f5d90537774f0ab8ec2d48291a08c59 | |
parent | 0d8f973905a4925e00eb9e32887c192b2148b29f (diff) | |
download | sdk-ac7efd7e9f6f9a9fd76afaa774f26ad76602c25a.zip sdk-ac7efd7e9f6f9a9fd76afaa774f26ad76602c25a.tar.gz sdk-ac7efd7e9f6f9a9fd76afaa774f26ad76602c25a.tar.bz2 |
Fix parsing SDK Tools in ant tasks.
Change-Id: Id1db4d2fc318b9318fcd0b7cb204f7ffe0d8429e
-rw-r--r-- | anttasks/src/com/android/ant/CheckEnvTask.java | 8 | ||||
-rw-r--r-- | anttasks/src/com/android/ant/TaskHelper.java | 9 |
2 files changed, 10 insertions, 7 deletions
diff --git a/anttasks/src/com/android/ant/CheckEnvTask.java b/anttasks/src/com/android/ant/CheckEnvTask.java index d6b6cc4..e8e1a89 100644 --- a/anttasks/src/com/android/ant/CheckEnvTask.java +++ b/anttasks/src/com/android/ant/CheckEnvTask.java @@ -42,7 +42,7 @@ public class CheckEnvTask extends Task { Project antProject = getProject(); // check the Ant version - DeweyDecimal version = getVersion(antProject); + DeweyDecimal version = getAntVersion(antProject); DeweyDecimal atLeast = new DeweyDecimal(ANT_MIN_VERSION); if (atLeast.isGreaterThan(version)) { throw new BuildException( @@ -67,8 +67,8 @@ public class CheckEnvTask extends Task { } // display SDK Tools revision - int toolsRevison = TaskHelper.getToolsRevision(sdkDir); - if (toolsRevison != -1) { + DeweyDecimal toolsRevison = TaskHelper.getToolsRevision(sdkDir); + if (toolsRevison != null) { System.out.println("Android SDK Tools Revision " + toolsRevison); System.out.println("Installed at " + sdkDir.getAbsolutePath()); } @@ -83,7 +83,7 @@ public class CheckEnvTask extends Task { * @param antProject the current ant project. * @return the ant version. */ - private DeweyDecimal getVersion(Project antProject) { + private DeweyDecimal getAntVersion(Project antProject) { char[] versionString = antProject.getProperty("ant.version").toCharArray(); StringBuilder sb = new StringBuilder(); boolean foundFirstDigit = false; diff --git a/anttasks/src/com/android/ant/TaskHelper.java b/anttasks/src/com/android/ant/TaskHelper.java index 3a372a1..35de033 100644 --- a/anttasks/src/com/android/ant/TaskHelper.java +++ b/anttasks/src/com/android/ant/TaskHelper.java @@ -17,6 +17,7 @@ package com.android.ant; import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.sdklib.SdkConstants; import com.android.sdklib.internal.project.ProjectProperties; import com.android.sdklib.internal.project.ProjectProperties.PropertyType; @@ -25,6 +26,7 @@ import com.android.sdklib.internal.project.ProjectPropertiesWorkingCopy; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.util.DeweyDecimal; import java.io.File; import java.io.FileInputStream; @@ -68,7 +70,8 @@ final class TaskHelper { * @param sdkFile the {@link File} for the root folder of the SDK * @return the tools revision or -1 if not found. */ - static int getToolsRevision(File sdkFile) { + @Nullable + static DeweyDecimal getToolsRevision(File sdkFile) { Properties p = new Properties(); try{ // tools folder must exist, or this custom task wouldn't run! @@ -90,7 +93,7 @@ final class TaskHelper { String value = p.getProperty("Pkg.Revision"); //$NON-NLS-1$ if (value != null) { - return Integer.parseInt(value); + return new DeweyDecimal(value); } } catch (FileNotFoundException e) { // couldn't find the file? return -1 below. @@ -98,7 +101,7 @@ final class TaskHelper { // couldn't find the file? return -1 below. } - return -1; + return null; } static String checkSinglePath(String attribute, Path path) { |