diff options
author | Raphael Moll <ralf@android.com> | 2012-06-20 15:07:38 -0700 |
---|---|---|
committer | Raphael Moll <ralf@android.com> | 2012-06-20 15:32:32 -0700 |
commit | b3862702e7dd316a9ec981bfeac1600f53b307d2 (patch) | |
tree | 1bd939a13da6a69153e7e841559d68ba5af0d523 /sdkmanager/app | |
parent | 5d061e69e06b24869cd290c83b8963a97de6a262 (diff) | |
download | sdk-b3862702e7dd316a9ec981bfeac1600f53b307d2.zip sdk-b3862702e7dd316a9ec981bfeac1600f53b307d2.tar.gz sdk-b3862702e7dd316a9ec981bfeac1600f53b307d2.tar.bz2 |
SDK Manager: new --clear-cache flag for command-line.
Change-Id: I2153a3f451567708ac25f992cdeaa0fb5f1adef3
Diffstat (limited to 'sdkmanager/app')
-rw-r--r-- | sdkmanager/app/src/com/android/sdkmanager/Main.java | 9 | ||||
-rw-r--r-- | sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java | 13 |
2 files changed, 22 insertions, 0 deletions
diff --git a/sdkmanager/app/src/com/android/sdkmanager/Main.java b/sdkmanager/app/src/com/android/sdkmanager/Main.java index 9cd0dd5..bbfbdcc 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/Main.java +++ b/sdkmanager/app/src/com/android/sdkmanager/Main.java @@ -36,6 +36,8 @@ import com.android.sdklib.internal.project.ProjectCreator; import com.android.sdklib.internal.project.ProjectCreator.OutputLevel; import com.android.sdklib.internal.project.ProjectProperties; import com.android.sdklib.internal.project.ProjectProperties.PropertyType; +import com.android.sdklib.internal.repository.DownloadCache; +import com.android.sdklib.internal.repository.DownloadCache.Strategy; import com.android.sdklib.internal.repository.packages.PlatformToolPackage; import com.android.sdklib.internal.repository.packages.ToolPackage; import com.android.sdklib.repository.SdkAddonConstants; @@ -229,6 +231,13 @@ public class Main { * Actually do an action... */ private void doAction() { + + if (mSdkCommandLine.hasClearCache()) { + DownloadCache d = new DownloadCache(Strategy.SERVE_CACHE); + d.clearCache(); + mSdkLog.printf("SDK Manager repository: manifest cache cleared.\n"); + } + String verb = mSdkCommandLine.getVerb(); String directObject = mSdkCommandLine.getDirectObject(); diff --git a/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java b/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java index b1325ee..56de068 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java +++ b/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java @@ -91,6 +91,7 @@ class SdkCommandLine extends CommandLineParser { public static final String KEY_ALIAS = "alias"; //$NON-NLS-1$ public static final String KEY_STOREPASS = "storepass"; //$NON-NLS-1$ public static final String KEY_KEYPASS = "keypass"; //$NON-NLS-1$ + public static final String KEY_CLEAR_CACHE = "clear-cache"; //$NON-NLS-1$ /** * Action definitions for SdkManager command line. @@ -165,6 +166,12 @@ class SdkCommandLine extends CommandLineParser { // The following defines the parameters of the actions defined in mAction. + // --- generic actions that can work on any verb --- + + define(Mode.BOOLEAN, false, + GLOBAL_FLAG_VERB, NO_VERB_OBJECT, ""/*shortName*/, KEY_CLEAR_CACHE, //$NON-NLS-1$ + "Clear the SDK Manager repository manifest cache.", false); //$NON-NLS-1$ + // --- list avds --- define(Mode.BOOLEAN, false, @@ -438,6 +445,12 @@ class SdkCommandLine extends CommandLineParser { // -- some helpers for generic action flags + /** Helper that returns true if --verbose was requested. */ + public boolean hasClearCache() { + return + ((Boolean) getValue(GLOBAL_FLAG_VERB, NO_VERB_OBJECT, KEY_CLEAR_CACHE)).booleanValue(); + } + /** Helper to retrieve the --path value. */ public String getParamLocationPath() { return (String) getValue(null, null, KEY_PATH); |