SdkDownloader refactoring, updated to last android tools
This commit is contained in:
@@ -46,6 +46,10 @@ public class PathManager {
|
|||||||
return getAndroidSdkRoot() + "/tools";
|
return getAndroidSdkRoot() + "/tools";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBuildToolsFolderInAndroidSdk() {
|
||||||
|
return getAndroidSdkRoot() + "/build-tools";
|
||||||
|
}
|
||||||
|
|
||||||
public String getOutputForCompiledFiles() {
|
public String getOutputForCompiledFiles() {
|
||||||
return tmpFolder + "/libs/codegen-test-output";
|
return tmpFolder + "/libs/codegen-test-output";
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-32
@@ -31,79 +31,90 @@ public class SDKDownloader {
|
|||||||
private final String platformZipPath;
|
private final String platformZipPath;
|
||||||
private final String systemImages;
|
private final String systemImages;
|
||||||
private final String platformToolsZipPath;
|
private final String platformToolsZipPath;
|
||||||
private final String toolsZipPath;
|
private final String skdToolsZipPath;
|
||||||
|
private final String buildToolsZipPath;
|
||||||
|
|
||||||
private final PathManager pathManager;
|
private final PathManager pathManager;
|
||||||
|
|
||||||
|
private static final String PLATFORM_TOOLS = "23.1.0";
|
||||||
|
private static final String SDK_TOOLS = "25.1.1";
|
||||||
|
public static final String BUILD_TOOLS = "23.0.3";
|
||||||
|
private static final int ANDROID_VERSION = 16;
|
||||||
|
|
||||||
|
|
||||||
public SDKDownloader(PathManager pathManager) {
|
public SDKDownloader(PathManager pathManager) {
|
||||||
this.pathManager = pathManager;
|
this.pathManager = pathManager;
|
||||||
this.platformZipPath = pathManager.getRootForDownload() + "/platforms.zip";
|
platformZipPath = pathManager.getRootForDownload() + "/platforms.zip";
|
||||||
this.systemImages = pathManager.getRootForDownload() + "/system-images.zip";
|
systemImages = pathManager.getRootForDownload() + "/system-images.zip";
|
||||||
this.platformToolsZipPath = pathManager.getRootForDownload() + "/platform-tools.zip";
|
platformToolsZipPath = pathManager.getRootForDownload() + "/platform-tools.zip";
|
||||||
this.toolsZipPath = pathManager.getRootForDownload() + "/tools.zip";
|
skdToolsZipPath = pathManager.getRootForDownload() + "/tools.zip";
|
||||||
|
buildToolsZipPath = pathManager.getRootForDownload() + "/build-tools.zip";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadPlatform() {
|
public void downloadPlatform() {
|
||||||
download("http://dl-ssl.google.com/android/repository/android-16_r04.zip", platformZipPath); //Same for all platforms
|
download("http://dl-ssl.google.com/android/repository/android-" + ANDROID_VERSION + "_r05.zip", platformZipPath); //Same for all platforms
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadAbi() {
|
private void downloadAbi() {
|
||||||
download("http://dl.google.com/android/repository/sysimg_armv7a-16_r03.zip", systemImages); //Same for all platforms
|
download("http://dl.google.com/android/repository/sys-img/android/sysimg_armv7a-" + ANDROID_VERSION + "_r04.zip", systemImages); //Same for all platforms
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadPlatformTools() {
|
public void downloadPlatformTools() {
|
||||||
String downloadURL;
|
download(getDownloadUrl("http://dl-ssl.google.com/android/repository/platform-tools_r" + PLATFORM_TOOLS), platformToolsZipPath);
|
||||||
if (SystemInfo.isWindows) {
|
|
||||||
downloadURL = "http://dl-ssl.google.com/android/repository/platform-tools_r16-windows.zip";
|
|
||||||
}
|
|
||||||
else if (SystemInfo.isMac) {
|
|
||||||
downloadURL = "http://dl-ssl.google.com/android/repository/platform-tools_r16-macosx.zip";
|
|
||||||
}
|
|
||||||
else if (SystemInfo.isUnix) {
|
|
||||||
downloadURL = "http://dl-ssl.google.com/android/repository/platform-tools_r16-linux.zip";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new IllegalStateException("Your operating system doesn't supported yet.");
|
|
||||||
}
|
|
||||||
download(downloadURL, platformToolsZipPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadTools() {
|
public void downloadSdkTools() {
|
||||||
String downloadURL;
|
download(getDownloadUrl("http://dl.google.com/android/repository/tools_r" + SDK_TOOLS), skdToolsZipPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void downloadBuildTools() {
|
||||||
|
download(getDownloadUrl("http://dl.google.com/android/repository/build-tools_r" + BUILD_TOOLS), buildToolsZipPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getDownloadUrl(String prefix) {
|
||||||
|
String suffix;
|
||||||
if (SystemInfo.isWindows) {
|
if (SystemInfo.isWindows) {
|
||||||
downloadURL = "http://dl.google.com/android/repository/tools_r16-windows.zip";
|
suffix = "-windows.zip";
|
||||||
}
|
}
|
||||||
else if (SystemInfo.isMac) {
|
else if (SystemInfo.isMac) {
|
||||||
downloadURL = "http://dl.google.com/android/repository/tools_r16-macosx.zip";
|
suffix = "-macosx.zip";
|
||||||
}
|
}
|
||||||
else if (SystemInfo.isUnix) {
|
else if (SystemInfo.isUnix) {
|
||||||
downloadURL = "http://dl.google.com/android/repository/tools_r16-linux.zip";
|
suffix = "-linux.zip";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new IllegalStateException("Your operating system doesn't supported yet.");
|
throw new IllegalStateException("Your operating system doesn't supported yet.");
|
||||||
}
|
}
|
||||||
download(downloadURL, toolsZipPath);
|
return prefix + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadAll() {
|
public void downloadAll() {
|
||||||
downloadTools();
|
downloadSdkTools();
|
||||||
downloadAbi();
|
downloadAbi();
|
||||||
downloadPlatform();
|
downloadPlatform();
|
||||||
downloadPlatformTools();
|
downloadPlatformTools();
|
||||||
|
downloadBuildTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void unzipAll() {
|
public void unzipAll() {
|
||||||
|
String androidSdkRoot = pathManager.getAndroidSdkRoot();
|
||||||
unzip(platformZipPath, pathManager.getPlatformFolderInAndroidSdk());
|
unzip(platformZipPath, pathManager.getPlatformFolderInAndroidSdk());
|
||||||
unzip(systemImages, pathManager.getAndroidSdkRoot() + "/system-images/android-16/");
|
unzip(systemImages, androidSdkRoot + "/system-images/android-" + ANDROID_VERSION + "/");
|
||||||
unzip(platformToolsZipPath, pathManager.getAndroidSdkRoot());
|
unzip(platformToolsZipPath, androidSdkRoot);
|
||||||
unzip(toolsZipPath, pathManager.getAndroidSdkRoot());
|
unzip(skdToolsZipPath, androidSdkRoot);
|
||||||
|
String buildTools = androidSdkRoot + "/build-tools/";
|
||||||
|
String buildToolsFolder = buildTools + BUILD_TOOLS + "/";
|
||||||
|
new File(buildToolsFolder).delete();
|
||||||
|
unzip(buildToolsZipPath, buildTools);
|
||||||
|
new File(buildTools + "/android-6.0").renameTo(new File(buildToolsFolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAll() {
|
public void deleteAll() {
|
||||||
delete(platformZipPath);
|
delete(platformZipPath);
|
||||||
delete(platformToolsZipPath);
|
delete(platformToolsZipPath);
|
||||||
delete(toolsZipPath);
|
delete(skdToolsZipPath);
|
||||||
|
delete(buildToolsZipPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void download(String urlString, String output) {
|
private static void download(String urlString, String output) {
|
||||||
|
|||||||
Reference in New Issue
Block a user