Search in sources :

Example 1 with LocalProperties

use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.

the class NativeDebuggerGuiTestRule method updateLocalProperties.

@Override
protected void updateLocalProperties(@NotNull File projectPath) throws IOException {
    super.updateLocalProperties(projectPath);
    LocalProperties localProperties = new LocalProperties(projectPath);
    localProperties.setAndroidNdkPath(getAndroidNdkPath());
    localProperties.save();
}
Also used : LocalProperties(com.android.tools.idea.gradle.util.LocalProperties)

Example 2 with LocalProperties

use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.

the class AndroidGradleTestCase method updateLocalProperties.

private void updateLocalProperties() throws IOException {
    LocalProperties localProperties = new LocalProperties(getProject());
    File sdkPath = getSdk();
    assertAbout(file()).that(sdkPath).named("Android SDK path").isDirectory();
    localProperties.setAndroidSdkPath(sdkPath.getPath());
    localProperties.save();
}
Also used : LocalProperties(com.android.tools.idea.gradle.util.LocalProperties) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) TestUtils.getWorkspaceFile(com.android.testutils.TestUtils.getWorkspaceFile)

Example 3 with LocalProperties

use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.

the class GradleSyncTest method sdkSwitch.

// Verifies that the IDE switches SDKs if the IDE and project SDKs are not the same.
@Test
public void sdkSwitch() throws IOException {
    File secondSdkPath = getFilePathPropertyOrSkipTest("second.android.sdk.path", "the path of a secondary Android SDK", true);
    getGuiTestSuiteState().setSkipSdkMerge(true);
    IdeSdks ideSdks = IdeSdks.getInstance();
    File originalSdkPath = ideSdks.getAndroidSdkPath();
    guiTest.importSimpleApplication();
    IdeFrameFixture ideFrame = guiTest.ideFrame();
    // Change the SDK in the project. We expect the IDE to have the same SDK as the project.
    LocalProperties localProperties = new LocalProperties(ideFrame.getProject());
    localProperties.setAndroidSdkPath(secondSdkPath);
    localProperties.save();
    ideFrame.requestProjectSync();
    MessagesFixture messages = ideFrame.findMessageDialog(ANDROID_SDK_MANAGER_DIALOG_TITLE);
    messages.click("Use Project's SDK");
    ideFrame.waitForGradleProjectSyncToFinish();
    assertThat(ideSdks.getAndroidSdkPath()).isEqualTo(secondSdkPath);
    // Set the project's SDK to be the original one. Now we will choose the IDE's SDK.
    localProperties = new LocalProperties(ideFrame.getProject());
    localProperties.setAndroidSdkPath(originalSdkPath);
    localProperties.save();
    ideFrame.requestProjectSync();
    messages = ideFrame.findMessageDialog(ANDROID_SDK_MANAGER_DIALOG_TITLE);
    messages.click("Use Android Studio's SDK");
    ideFrame.waitForGradleProjectSyncToFinish();
    localProperties = new LocalProperties(ideFrame.getProject());
    assertThat(localProperties.getAndroidSdkPath()).isEqualTo(secondSdkPath);
}
Also used : IdeSdks(com.android.tools.idea.sdk.IdeSdks) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtil.findFileByIoFile(com.intellij.openapi.vfs.VfsUtil.findFileByIoFile) GradleBuildFile(com.android.tools.idea.gradle.parser.GradleBuildFile) File(java.io.File) GradleUtil.getGradleBuildFile(com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile) LocalProperties(com.android.tools.idea.gradle.util.LocalProperties) Test(org.junit.Test)

Example 4 with LocalProperties

use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.

the class SdkSync method syncIdeAndProjectAndroidSdks.

public void syncIdeAndProjectAndroidSdks(@NotNull Project project) throws IOException {
    LocalProperties localProperties = new LocalProperties(project);
    syncIdeAndProjectAndroidSdk(localProperties, new FindValidSdkPathTask(myIdeSdks), project);
    syncIdeAndProjectAndroidNdk(localProperties);
}
Also used : LocalProperties(com.android.tools.idea.gradle.util.LocalProperties)

Example 5 with LocalProperties

use of com.android.tools.idea.gradle.util.LocalProperties in project android by JetBrains.

the class NewGradleSyncTest method createLocalPropertiesFile.

private void createLocalPropertiesFile(@NotNull File androidSdkPath) throws IOException {
    LocalProperties localProperties = new LocalProperties(getProject());
    localProperties.setAndroidSdkPath(androidSdkPath);
    localProperties.save();
}
Also used : LocalProperties(com.android.tools.idea.gradle.util.LocalProperties)

Aggregations

LocalProperties (com.android.tools.idea.gradle.util.LocalProperties)17 File (java.io.File)8 IOException (java.io.IOException)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 HashSet (com.intellij.util.containers.HashSet)2 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)2 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)2 TestUtils.getWorkspaceFile (com.android.testutils.TestUtils.getWorkspaceFile)1 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 GradleUtil.getGradleBuildFile (com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile)1 IdeSdks (com.android.tools.idea.sdk.IdeSdks)1 ExternalSystemException (com.intellij.openapi.externalSystem.model.ExternalSystemException)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 PsiFile (com.intellij.psi.PsiFile)1 List (java.util.List)1 NotNull (org.jetbrains.annotations.NotNull)1 Test (org.junit.Test)1