use of com.android.tools.idea.sdk.AndroidSdks in project android by JetBrains.
the class AndroidFacetImporterBase method createNewAndroidSdkForMaven.
@Nullable
private static Sdk createNewAndroidSdkForMaven(File sdkPath, IAndroidTarget target) {
AndroidSdks androidSdks = AndroidSdks.getInstance();
Sdk sdk = null;
Sdk jdk = Jdks.getInstance().chooseOrCreateJavaSdk();
if (jdk != null) {
String sdkName = "Maven " + androidSdks.chooseNameForNewLibrary(target);
sdk = androidSdks.create(target, sdkPath, sdkName, jdk, false);
}
if (sdk == null) {
return null;
}
SdkModificator modificator = sdk.getSdkModificator();
for (OrderRoot root : androidSdks.getLibraryRootsForTarget(target, sdkPath, false)) {
modificator.addRoot(root.getFile(), root.getType());
}
AndroidSdkAdditionalData data = androidSdks.getAndroidSdkAdditionalData(sdk);
if (data != null) {
final Sdk javaSdk = data.getJavaSdk();
if (javaSdk != null) {
for (VirtualFile file : javaSdk.getRootProvider().getFiles(OrderRootType.CLASSES)) {
modificator.addRoot(file, OrderRootType.CLASSES);
}
} else {
LOG.error("AndroidSdkUtils.createNewAndroidPlatform should return Android SDK with a valid JDK reference, or return null");
}
}
modificator.commitChanges();
return sdk;
}
Aggregations