use of org.jetbrains.android.sdk.AndroidSdkAdditionalData in project android by JetBrains.
the class AndroidSdksTest method testCreateSdkWithoutAddingRoots.
public void testCreateSdkWithoutAddingRoots() {
IAndroidTarget target = findAndroidTarget();
String name = "testSdk";
Sdk sdk = myAndroidSdks.create(target, mySdkPath, name, myJdk, false);
assertNotNull(sdk);
assertEquals(name, sdk.getName());
verifyCorrectPath(sdk);
AndroidSdkAdditionalData androidData = getAndroidSdkAdditionalData(sdk);
assertSame(myJdk, androidData.getJavaSdk());
AndroidPlatform androidPlatform = androidData.getAndroidPlatform();
assertNotNull(androidPlatform);
assertSame(target, androidPlatform.getTarget());
VirtualFile[] sdkRoots = sdk.getSdkModificator().getRoots(CLASSES);
assertThat(sdkRoots).isEmpty();
}
use of org.jetbrains.android.sdk.AndroidSdkAdditionalData 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