mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move createSdkManager() to AndroidCommonUtils
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
package org.jetbrains.android.util;
|
||||
|
||||
import com.android.sdklib.ISdkLog;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.android.sdklib.SdkManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -11,7 +18,7 @@ import java.util.Iterator;
|
||||
*/
|
||||
public class AndroidCommonUtils {
|
||||
@NonNls public static final Object MANIFEST_JAVA_FILE_NAME = "Manifest.java";
|
||||
public static final String R_JAVA_FILENAME = "R.java";
|
||||
@NonNls public static final String R_JAVA_FILENAME = "R.java";
|
||||
|
||||
private AndroidCommonUtils() {
|
||||
}
|
||||
@@ -29,4 +36,37 @@ public class AndroidCommonUtils {
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SdkManager createSdkManager(@NotNull String path, @NotNull ISdkLog log) {
|
||||
path = FileUtil.toSystemDependentName(path);
|
||||
|
||||
final File f = new File(path);
|
||||
if (!f.exists() || !f.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final File platformsDir = new File(f, SdkConstants.FD_PLATFORMS);
|
||||
if (!platformsDir.exists() || !platformsDir.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return SdkManager.createManager(path + File.separatorChar, log);
|
||||
}
|
||||
|
||||
public static void moveAllFiles(@NotNull File from, @NotNull File to, @NotNull Collection<File> newFiles) throws IOException {
|
||||
if (from.isFile()) {
|
||||
FileUtil.rename(from, to);
|
||||
newFiles.add(to);
|
||||
}
|
||||
else {
|
||||
final File[] children = from.listFiles();
|
||||
|
||||
if (children != null) {
|
||||
for (File child : children) {
|
||||
moveAllFiles(child, new File(to, child.getName()), newFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import org.jetbrains.android.actions.AndroidEnableDdmsAction;
|
||||
import org.jetbrains.android.util.AndroidCommonUtils;
|
||||
import org.jetbrains.android.util.AndroidUtils;
|
||||
import org.jetbrains.android.util.BufferingFileWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -152,7 +153,7 @@ public class AndroidSdk {
|
||||
|
||||
@Nullable
|
||||
public static AndroidSdk parse(@NotNull String path, @NotNull ISdkLog log) {
|
||||
final SdkManager manager = AndroidSdkUtils.createSdkManager(path, log);
|
||||
final SdkManager manager = AndroidCommonUtils.createSdkManager(path, log);
|
||||
return manager != null ? new AndroidSdk(manager, path) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
package org.jetbrains.android.sdk;
|
||||
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.ISdkLog;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.android.sdklib.SdkManager;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -36,12 +34,12 @@ import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.android.util.AndroidCommonUtils;
|
||||
import org.jetbrains.android.util.AndroidUtils;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -55,7 +53,7 @@ public class AndroidSdkUtils {
|
||||
}
|
||||
|
||||
public static boolean isAndroidSdk(@NotNull String path) {
|
||||
return createSdkManager(path, new EmptySdkLog()) != null;
|
||||
return AndroidCommonUtils.createSdkManager(path, new EmptySdkLog()) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -370,21 +368,4 @@ public class AndroidSdkUtils {
|
||||
public static void openModuleDependenciesConfigurable(final Module module) {
|
||||
ProjectSettingsService.getInstance(module.getProject()).openModuleDependenciesSettings(module, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SdkManager createSdkManager(@NotNull String path, @NotNull ISdkLog log) {
|
||||
path = FileUtil.toSystemDependentName(path);
|
||||
|
||||
final File f = new File(path);
|
||||
if (!f.exists() || !f.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final File platformsDir = new File(f, SdkConstants.FD_PLATFORMS);
|
||||
if (!platformsDir.exists() || !platformsDir.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return SdkManager.createManager(path + File.separatorChar, log);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user