use of org.jetbrains.android.sdk.AndroidSdkData in project android by JetBrains.
the class TemplateTest method testJdk7.
public void testJdk7() throws Exception {
if (DISABLED) {
return;
}
AndroidSdkData sdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
assertNotNull(sdkData);
if (IdeSdks.getInstance().isJdk7Supported(sdkData)) {
IAndroidTarget[] targets = sdkData.getTargets();
IAndroidTarget target = targets[targets.length - 1];
Map<String, Object> overrides = new HashMap<>();
overrides.put(ATTR_JAVA_VERSION, "1.7");
NewProjectWizardState state = createNewProjectState(true, sdkData);
// TODO: Allow null activity state!
File activity = findTemplate("activities", "BasicActivity");
TemplateWizardState activityState = state.getActivityTemplateState();
assertNotNull(activity);
activityState.setTemplateLocation(activity);
checkApiTarget(19, 19, target, state, "Test17", null, overrides, null);
} else {
System.out.println("JDK 7 not supported by current SDK manager: not testing");
}
}
use of org.jetbrains.android.sdk.AndroidSdkData in project android by JetBrains.
the class LintIdeApiDetectorTest method testTryWithResources.
// This test does not yet work reliably; need to ensure correct JDK 7 loading.
public void testTryWithResources() throws Exception {
// TODO: Allow setting a custom minSdkVersion in the manifest so I can test both with and without
AndroidSdkData sdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
if (sdkData == null || !IdeSdks.getInstance().isJdk7Supported(sdkData)) {
System.out.println("Skipping LintIdeApiDetectorTest#testTryWithResources: Test JDK must be JDK 7 or higher");
return;
}
AndroidLintNewApiInspection inspection = new AndroidLintNewApiInspection();
doTest(inspection, null);
}
use of org.jetbrains.android.sdk.AndroidSdkData in project android by JetBrains.
the class AndroidSdksTest method testTryToChooseSdkHandler.
public void testTryToChooseSdkHandler() {
myAndroidSdks.create(findAndroidTarget(), mySdkPath, myJdk, false);
AndroidSdkHandler sdkHandler = myAndroidSdks.tryToChooseSdkHandler();
AndroidSdkData sdkData = getSdkData(mySdkPath);
assertNotNull(sdkData);
assertSame(sdkData.getSdkHandler(), sdkHandler);
}
use of org.jetbrains.android.sdk.AndroidSdkData in project kotlin by JetBrains.
the class KotlinAndroidTestCaseBase method createAndroidSdk.
public Sdk createAndroidSdk(String sdkPath, String platformDir) {
Sdk sdk = ProjectJdkTable.getInstance().createSdk("android_test_sdk", AndroidSdkType.getInstance());
SdkModificator sdkModificator = sdk.getSdkModificator();
sdkModificator.setHomePath(sdkPath);
if (platformDir.equals(getDefaultPlatformDir())) {
// Compatibility: the unit tests were using android.jar outside the sdk1.5 install;
// we need to use that one, rather than the real one in sdk1.5, in order for the
// tests to pass. Longer term, we should switch the unit tests over to all using
// a valid SDK.
String androidJarPath = sdkPath + "/../android.jar!/";
androidJar = VirtualFileManager.getInstance().findFileByUrl("jar://" + androidJarPath);
} else {
androidJar = VirtualFileManager.getInstance().findFileByUrl("jar://" + sdkPath + "/platforms/" + platformDir + "/android.jar!/");
}
sdkModificator.addRoot(androidJar, OrderRootType.CLASSES);
VirtualFile resFolder = LocalFileSystem.getInstance().findFileByPath(sdkPath + "/platforms/" + platformDir + "/data/res");
sdkModificator.addRoot(resFolder, OrderRootType.CLASSES);
VirtualFile docsFolder = LocalFileSystem.getInstance().findFileByPath(sdkPath + "/docs/reference");
if (docsFolder != null) {
sdkModificator.addRoot(docsFolder, JavadocOrderRootType.getInstance());
}
AndroidSdkAdditionalData data = new AndroidSdkAdditionalData(sdk);
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdkPath);
assertNotNull(sdkData);
// TODO: Get rid of this hardcoded version number
IAndroidTarget target = sdkData.findTargetByName("Android 5.0");
if (target == null) {
IAndroidTarget[] targets = sdkData.getTargets();
for (IAndroidTarget t : targets) {
if (t.getLocation().contains(platformDir)) {
target = t;
break;
}
}
if (target == null && targets.length > 0) {
target = targets[targets.length - 1];
}
}
assertNotNull(target);
data.setBuildTarget(target);
sdkModificator.setSdkAdditionalData(data);
sdkModificator.commitChanges();
return sdk;
}
Aggregations