use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class GradleSpecificInitializer method checkAndSetSources.
private static void checkAndSetSources(@NotNull Sdk sdk) {
VirtualFile[] storedSources = sdk.getRootProvider().getFiles(OrderRootType.SOURCES);
if (storedSources.length > 0) {
return;
}
AndroidPlatform platform = AndroidPlatform.getInstance(sdk);
if (platform != null) {
SdkModificator sdkModificator = sdk.getSdkModificator();
IAndroidTarget target = platform.getTarget();
AndroidSdks.getInstance().findAndSetPlatformSources(target, sdkModificator);
sdkModificator.commitChanges();
}
}
use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class AndroidFacetImporterBase method isAppropriateSdk.
private boolean isAppropriateSdk(@NotNull Sdk sdk, MavenProject mavenProject) {
if (!AndroidSdks.getInstance().isAndroidSdk(sdk)) {
return false;
}
final String platformId = getPlatformFromConfig(mavenProject);
final AndroidPlatform androidPlatform = AndroidPlatform.getInstance(sdk);
if (androidPlatform == null) {
return false;
}
final IAndroidTarget target = androidPlatform.getTarget();
return (platformId == null || AndroidSdkUtils.targetHasId(target, platformId)) && AndroidSdkUtils.checkSdkRoots(sdk, target, true);
}
use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class AndroidLintTest method testGradlePlus.
/* Inspection disabled; these tests make network connection to MavenCentral and can change every time there
is a new version available (which makes for unstable tests)
public void testNewerAvailable() throws Exception {
GradleDetector.REMOTE_VERSION.setEnabledByDefault(true);
doTestWithFix(new AndroidLintInspectionToolProvider.AndroidLintNewerVersionAvailableInspection(),
"Update to 17.0.0", "build.gradle", "gradle");
}
*/
public void testGradlePlus() throws Exception {
// Needs a valid SDK; can't use the mock one in the test data.
AndroidSdkData prevSdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
if (prevSdkData == null) {
Sdk androidSdk = createLatestAndroidSdk();
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(androidSdk);
assertNotNull(androidPlatform);
// Put default platforms in the list before non-default ones so they'll be looked at first.
AndroidSdks.getInstance().setSdkData(androidPlatform.getSdkData());
}
//noinspection ConstantConditions
File sdk = AndroidSdks.getInstance().tryToChooseAndroidSdk().getLocation();
File appcompat = new File(sdk, "extras/android/m2repository/com/android/support/appcompat-v7/19.0.1".replace('/', File.separatorChar));
if (!appcompat.exists()) {
System.out.println("Not running " + this.getClass() + "#" + getName() + ": Needs SDK with Support Repo installed and " + "expected to find " + appcompat);
return;
}
// NOTE: The android support repository must be installed in the SDK used by the test!
doTestWithFix(new AndroidLintGradleDynamicVersionInspection(), "Replace with specific version", "build.gradle", "gradle");
AndroidSdks.getInstance().setSdkData(prevSdkData);
}
use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class RenderErrorContributorTest method stripSdkHome.
private String stripSdkHome(@NotNull String html) {
AndroidPlatform platform = AndroidPlatform.getInstance(myModule);
assertNotNull(platform);
String location = platform.getSdkData().getLocation().getPath();
location = FileUtil.toSystemIndependentName(location);
html = html.replace(location, "$SDK_HOME");
return html;
}
use of org.jetbrains.android.sdk.AndroidPlatform in project android by JetBrains.
the class AndroidJunitPatcherTest method getExampleClasspath.
private List<String> getExampleClasspath() {
myRoot = normalize(myAndroidProject.getRootDir().getPath());
List<String> exampleClassPath = Lists.newArrayList(myRoot + "/build/intermediates/classes/debug", myRoot + "/build/intermediates/classes/test/debug", myRoot + "/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/classes.jar", myRoot + "/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res", myRoot + "/build/intermediates/exploded-aar/com.android.support/support-v4/22.0.0/classes.jar", myRoot + "/build/intermediates/exploded-aar/com.android.support/support-v4/22.0.0/libs/internal_impl-22.0.0.jar", myRoot + "/build/intermediates/exploded-aar/com.android.support/support-v4/22.0.0/res", "/home/user/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar", "/idea/production/java-runtime", "/idea/production/junit_rt");
myMockableAndroidJar = myRoot + "/build/intermediates/mockable-" + TestUtils.getLatestAndroidPlatform() + ".jar";
AndroidPlatform androidPlatform = AndroidPlatform.getInstance(myModule);
assertNotNull(androidPlatform);
myRealAndroidJar = TestUtils.getPlatformFile("android.jar").toString();
myResourcesDirs = ImmutableList.of(myRoot + "/build/intermediates/javaResources/debug", myRoot + "/build/intermediates/javaResources/test/debug");
exampleClassPath.add(0, myMockableAndroidJar);
exampleClassPath.add(0, myRealAndroidJar);
myExampleClassPathSet = ImmutableSet.copyOf(exampleClassPath);
// Sanity check. These should be fixed by the patcher.
assertContainsElements(exampleClassPath, myRealAndroidJar);
assertContainsElements(exampleClassPath, myMockableAndroidJar);
assertDoesntContain(exampleClassPath, myResourcesDirs);
assertFalse(Iterables.getLast(exampleClassPath).equals(myMockableAndroidJar));
return exampleClassPath;
}
Aggregations