use of org.jetbrains.android.sdk.AndroidSdkData in project android by JetBrains.
the class AndroidSdksTest method testSetSdkData.
public void testSetSdkData() {
AndroidSdkData data = mock(AndroidSdkData.class);
myAndroidSdks.setSdkData(data);
assertSame(data, myAndroidSdks.tryToChooseAndroidSdk());
}
use of org.jetbrains.android.sdk.AndroidSdkData in project android by JetBrains.
the class AndroidSdksTest method findAndroidTarget.
@NotNull
private IAndroidTarget findAndroidTarget() {
AndroidSdkData sdkData = getSdkData(mySdkPath);
assertNotNull(sdkData);
IAndroidTarget[] targets = sdkData.getTargets(false);
assertThat(targets).isNotEmpty();
// Use the latest platform, which is checked-in as a full SDK. Older platforms may not be checked in full, to save space.
IAndroidTarget result = ContainerUtil.find(targets, target -> target.hashString().equals(TestUtils.getLatestAndroidPlatform()));
assertThat(result).isNotNull();
return result;
}
use of org.jetbrains.android.sdk.AndroidSdkData in project android by JetBrains.
the class AndroidSdksTest method testTryToChooseAndroidSdk.
public void testTryToChooseAndroidSdk() {
myAndroidSdks.create(findAndroidTarget(), mySdkPath, myJdk, false);
AndroidSdkData sdkData = myAndroidSdks.tryToChooseAndroidSdk();
assertSame(getSdkData(mySdkPath), sdkData);
}
use of org.jetbrains.android.sdk.AndroidSdkData in project android by JetBrains.
the class IdeSdksTest method assertOneSdkPerAvailableTarget.
private void assertOneSdkPerAvailableTarget(@NotNull List<Sdk> sdks) {
List<IAndroidTarget> platformTargets = Lists.newArrayList();
AndroidSdkData sdkData = AndroidSdkData.getSdkData(myAndroidSdkPath);
assertNotNull(sdkData);
for (IAndroidTarget target : sdkData.getTargets()) {
if (target.isPlatform()) {
platformTargets.add(target);
}
}
assertEquals(platformTargets.size(), sdks.size());
for (Sdk sdk : sdks) {
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(sdk);
assertNotNull(androidPlatform);
IAndroidTarget target = androidPlatform.getTarget();
platformTargets.remove(target);
}
assertEquals(0, platformTargets.size());
}
use of org.jetbrains.android.sdk.AndroidSdkData in project android by JetBrains.
the class SdksCleanupStep method shouldRemoveAnnotationsJar.
/*
* Indicates whether annotations.jar should be removed from the given SDK (if it is an Android SDK.)
* There are 2 issues:
* 1. annotations.jar is not needed for API level 16 and above. The annotations are already included in android.jar. Until recently, the
* IDE added annotations.jar to the IDEA Android SDK definition unconditionally.
* 2. Because annotations.jar is in the classpath, the IDE locks the file on Windows making automatic updates of SDK Tools fail. The
* update not only fails, it corrupts the 'tools' folder in the SDK.
* From now on, creating IDEA Android SDKs will not include annotations.jar if API level is 16 or above, but we still need to remove
* this jar from existing IDEA Android SDKs.
*/
private boolean shouldRemoveAnnotationsJar(@NotNull Sdk sdk) {
if (myAndroidSdks.isAndroidSdk(sdk)) {
AndroidSdkAdditionalData additionalData = myAndroidSdks.getAndroidSdkAdditionalData(sdk);
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdk);
boolean needsAnnotationsJar = false;
if (additionalData != null && sdkData != null) {
IAndroidTarget target = additionalData.getBuildTarget(sdkData);
if (target != null) {
needsAnnotationsJar = myAndroidSdks.needsAnnotationsJarInClasspath(target);
}
}
for (VirtualFile library : sdk.getRootProvider().getFiles(CLASSES)) {
// annotations.jar and res folder.
if (library.getName().equals(FN_ANNOTATIONS_JAR) && library.exists() && !needsAnnotationsJar) {
return true;
}
}
}
return false;
}
Aggregations