aboutsummaryrefslogtreecommitdiffstats
path: root/anttasks
diff options
context:
space:
mode:
authorRaphael Moll <ralf@android.com>2010-08-10 10:20:46 -0700
committerRaphael Moll <ralf@android.com>2010-08-10 10:20:46 -0700
commit1cfea05df04b8cff0fc4d2d9ee62e58009e4e35f (patch)
tree077b2f479519d2376754be71f1f596fea5ab45b8 /anttasks
parent271fe07ba885bd17784c0a28e4a5b6b7c3034015 (diff)
downloadsdk-1cfea05df04b8cff0fc4d2d9ee62e58009e4e35f.zip
sdk-1cfea05df04b8cff0fc4d2d9ee62e58009e4e35f.tar.gz
sdk-1cfea05df04b8cff0fc4d2d9ee62e58009e4e35f.tar.bz2
Ant: ensure SDK path ends with dir separator.
SDK Bug: 2906094 Change-Id: Ic4053c97c8dd5a32a2276e22644b5e09c91d52f0
Diffstat (limited to 'anttasks')
-rw-r--r--anttasks/src/com/android/ant/SetupTask.java30
-rw-r--r--anttasks/src/com/android/ant/TaskHelper.java17
2 files changed, 28 insertions, 19 deletions
diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java
index 0cd3e19..c66b956 100644
--- a/anttasks/src/com/android/ant/SetupTask.java
+++ b/anttasks/src/com/android/ant/SetupTask.java
@@ -119,11 +119,16 @@ public final class SetupTask extends ImportTask {
Project antProject = getProject();
// get the SDK location
- File sdk = TaskHelper.getSdkLocation(antProject);
- String sdkLocation = sdk.getPath();
+ File sdkDir = TaskHelper.getSdkLocation(antProject);
+ String sdkOsPath = sdkDir.getPath();
+
+ // Make sure the OS sdk path ends with a directory separator
+ if (sdkOsPath.length() > 0 && !sdkOsPath.endsWith(File.separator)) {
+ sdkOsPath += File.separator;
+ }
// display SDK Tools revision
- int toolsRevison = TaskHelper.getToolsRevision(sdk);
+ int toolsRevison = TaskHelper.getToolsRevision(sdkDir);
if (toolsRevison != -1) {
System.out.println("Android SDK Tools Revision " + toolsRevison);
}
@@ -143,7 +148,7 @@ public final class SetupTask extends ImportTask {
// load up the sdk targets.
final ArrayList<String> messages = new ArrayList<String>();
- SdkManager manager = SdkManager.createManager(sdkLocation, new ISdkLog() {
+ SdkManager manager = SdkManager.createManager(sdkOsPath, new ISdkLog() {
public void error(Throwable t, String errorFormat, Object... args) {
if (errorFormat != null) {
messages.add(String.format("Error: " + errorFormat, args));
@@ -310,7 +315,7 @@ public final class SetupTask extends ImportTask {
rulesFolder = new File(rulesOSPath);
} else {
// in this case we import the rules from the ant folder in the tools.
- rulesFolder = new File(new File(sdkLocation, SdkConstants.FD_TOOLS),
+ rulesFolder = new File(new File(sdkOsPath, SdkConstants.FD_TOOLS),
SdkConstants.FD_ANT);
// the new rev is:
antBuildVersion = toolsRulesRev;
@@ -329,7 +334,7 @@ public final class SetupTask extends ImportTask {
} else {
importedRulesFileName = String.format(
isLibrary ? RULES_LIBRARY : isTestProject ? RULES_TEST : RULES_MAIN,
- antBuildVersion);;
+ antBuildVersion);
}
// now check the rules file exists.
@@ -342,14 +347,14 @@ public final class SetupTask extends ImportTask {
// display the file being imported.
// figure out the path relative to the SDK
- String rulesLocation = rules.getAbsolutePath();
- if (rulesLocation.startsWith(sdkLocation)) {
- rulesLocation = rulesLocation.substring(sdkLocation.length());
- if (rulesLocation.startsWith(File.separator)) {
- rulesLocation = rulesLocation.substring(1);
+ String rulesOsPath = rules.getAbsolutePath();
+ if (rulesOsPath.startsWith(sdkOsPath)) {
+ rulesOsPath = rulesOsPath.substring(sdkOsPath.length());
+ if (rulesOsPath.startsWith(File.separator)) {
+ rulesOsPath = rulesOsPath.substring(1);
}
}
- System.out.println("\nImporting rules file: " + rulesLocation);
+ System.out.println("\nImporting rules file: " + rulesOsPath);
// set the file location to import
setFile(rules.getAbsolutePath());
@@ -624,7 +629,6 @@ public final class SetupTask extends ImportTask {
* project properties.
* @param baseFolder the base folder of the project (to resolve relative paths)
* @param source a source of project properties.
- * @return
*/
private ArrayList<File> getDirectDependencies(File baseFolder, IPropertySource source) {
ArrayList<File> libraries = new ArrayList<File>();
diff --git a/anttasks/src/com/android/ant/TaskHelper.java b/anttasks/src/com/android/ant/TaskHelper.java
index 22cfb30..e29175b 100644
--- a/anttasks/src/com/android/ant/TaskHelper.java
+++ b/anttasks/src/com/android/ant/TaskHelper.java
@@ -35,22 +35,27 @@ final class TaskHelper {
static File getSdkLocation(Project antProject) {
// get the SDK location
- String sdkLocation = antProject.getProperty(ProjectProperties.PROPERTY_SDK);
+ String sdkOsPath = antProject.getProperty(ProjectProperties.PROPERTY_SDK);
// check if it's valid and exists
- if (sdkLocation == null || sdkLocation.length() == 0) {
+ if (sdkOsPath == null || sdkOsPath.length() == 0) {
// LEGACY support: project created with 1.6 or before may be using a different
// property to declare the location of the SDK. At this point, we cannot
// yet check which target is running so we check both always.
- sdkLocation = antProject.getProperty(ProjectProperties.PROPERTY_SDK_LEGACY);
- if (sdkLocation == null || sdkLocation.length() == 0) {
+ sdkOsPath = antProject.getProperty(ProjectProperties.PROPERTY_SDK_LEGACY);
+ if (sdkOsPath == null || sdkOsPath.length() == 0) {
throw new BuildException("SDK Location is not set.");
}
}
- File sdk = new File(sdkLocation);
+ // Make sure the OS sdk path ends with a directory separator
+ if (sdkOsPath.length() > 0 && !sdkOsPath.endsWith(File.separator)) {
+ sdkOsPath += File.separator;
+ }
+
+ File sdk = new File(sdkOsPath);
if (sdk.isDirectory() == false) {
- throw new BuildException(String.format("SDK Location '%s' is not valid.", sdkLocation));
+ throw new BuildException(String.format("SDK Location '%s' is not valid.", sdkOsPath));
}
return sdk;