aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Moll <ralf@android.com>2011-01-12 13:54:53 -0800
committerRaphael Moll <ralf@android.com>2011-01-12 15:30:46 -0800
commita8f23d68b957b4b341755b2a9bdd9495da6696c7 (patch)
tree407401af89677fca5f1b6d96cd03862990a59bca
parent8309bc58458a514915f17966e6bd08d0a18308c9 (diff)
downloadsdk-a8f23d68b957b4b341755b2a9bdd9495da6696c7.zip
sdk-a8f23d68b957b4b341755b2a9bdd9495da6696c7.tar.gz
sdk-a8f23d68b957b4b341755b2a9bdd9495da6696c7.tar.bz2
Make it possible to override the SDK path using an env var
The value will only be used if it matches an existing directory. Useful for testing from Eclipse. Note: this is a hack that does not change the preferences, so if the user looks at Window > Preferences > Android, the path will be the preferences one and not the overriden one. Change-Id: I70fb1a7117f56d4c6e5cab253c3323480605413f
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/AdtPrefs.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/AdtPrefs.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/AdtPrefs.java
index de5847b..6c38ff4 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/AdtPrefs.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/AdtPrefs.java
@@ -117,6 +117,17 @@ public final class AdtPrefs extends AbstractPreferenceInitializer {
if (property == null || PREFS_SDK_DIR.equals(property)) {
mOsSdkLocation = mStore.getString(PREFS_SDK_DIR);
+ // Make it possible to override the SDK path using an environment variable.
+ // The value will only be used if it matches an existing directory.
+ // Useful for testing from Eclipse.
+ // Note: this is a hack that does not change the preferences, so if the user
+ // looks at Window > Preferences > Android, the path will be the preferences
+ // one and not the overridden one.
+ String override = System.getenv("ADT_TEST_SDK_PATH"); //$NON-NLS-1$
+ if (override != null && override.length() > 0 && new File(override).isDirectory()) {
+ mOsSdkLocation = override;
+ }
+
// make sure it ends with a separator. Normally this is done when the preference
// is set. But to make sure older version still work, we fix it here as well.
if (mOsSdkLocation.length() > 0 && mOsSdkLocation.endsWith(File.separator) == false) {