Search in sources :

Example 11 with GradleSyncState

use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.

the class GradleProjectSyncDataTest method testEndToEnd.

public void testEndToEnd() throws Exception {
    loadProject(PROJECT_WITH_APPAND_LIB);
    Project project = myAndroidFacet.getModule().getProject();
    GradleSyncState syncState = GradleSyncState.getInstance(project);
    long previousSyncTime = syncState.getSummary().getSyncTimestamp();
    GradleProjectSyncData data = GradleProjectSyncData.createFrom(project);
    verifyGradleProjectSyncData(data, previousSyncTime);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(outputStream);
    oos.writeObject(data);
    oos.close();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(inputStream);
    GradleProjectSyncData newData = (GradleProjectSyncData) ois.readObject();
    ois.close();
    verifyGradleProjectSyncData(newData, previousSyncTime);
}
Also used : Project(com.intellij.openapi.project.Project) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState)

Example 12 with GradleSyncState

use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.

the class GradleProjectInfoTest method registerLastSyncTimestamp.

private void registerLastSyncTimestamp(long timestamp) {
    GradleSyncSummary summary = mock(GradleSyncSummary.class);
    when(summary.getSyncTimestamp()).thenReturn(timestamp);
    GradleSyncState syncState = IdeComponents.replaceServiceWithMock(getProject(), GradleSyncState.class);
    when(syncState.getSummary()).thenReturn(summary);
}
Also used : GradleSyncSummary(com.android.tools.idea.gradle.project.sync.GradleSyncSummary) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState)

Example 13 with GradleSyncState

use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.

the class GradleBuildInvokerTest method simulateLastSyncFailed.

private void simulateLastSyncFailed(boolean failed) {
    GradleSyncState syncState = IdeComponents.replaceServiceWithMock(getProject(), GradleSyncState.class);
    when(syncState.lastSyncFailed()).thenReturn(failed);
}
Also used : GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState)

Example 14 with GradleSyncState

use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.

the class IdeFrameFixture method waitForGradleProjectSyncToStart.

@NotNull
public IdeFrameFixture waitForGradleProjectSyncToStart() {
    Project project = getProject();
    GradleSyncState syncState = GradleSyncState.getInstance(project);
    if (!syncState.isSyncInProgress()) {
        Wait.seconds(10).expecting("Syncing project " + quote(project.getName()) + " to finish").until(myGradleProjectEventListener::isSyncStarted);
    }
    return this;
}
Also used : Project(com.intellij.openapi.project.Project) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with GradleSyncState

use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.

the class IdeFrameFixture method waitForGradleProjectSyncToFinish.

private void waitForGradleProjectSyncToFinish(boolean expectSyncFailure) {
    Project project = getProject();
    // ensure GradleInvoker (in-process build) is always enabled.
    AndroidGradleBuildConfiguration buildConfiguration = AndroidGradleBuildConfiguration.getInstance(project);
    buildConfiguration.USE_EXPERIMENTAL_FASTER_BUILD = true;
    Wait.seconds(10).expecting("Syncing project " + quote(project.getName()) + " to finish").until(() -> {
        GradleSyncState syncState = GradleSyncState.getInstance(project);
        boolean syncFinished = (myGradleProjectEventListener.isSyncFinished() || syncState.isSyncNeeded() != ThreeState.YES) && !syncState.isSyncInProgress();
        if (expectSyncFailure) {
            syncFinished = syncFinished && myGradleProjectEventListener.hasSyncError();
        }
        return syncFinished;
    });
    waitForGradleSyncAction();
    if (myGradleProjectEventListener.hasSyncError()) {
        RuntimeException syncError = myGradleProjectEventListener.getSyncError();
        myGradleProjectEventListener.reset();
        throw syncError;
    }
    if (!myGradleProjectEventListener.isSyncSkipped()) {
        waitForBuildToFinish(SOURCE_GEN);
    }
    GuiTests.waitForBackgroundTasks(robot());
}
Also used : Project(com.intellij.openapi.project.Project) AndroidGradleBuildConfiguration(com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState)

Aggregations

GradleSyncState (com.android.tools.idea.gradle.project.sync.GradleSyncState)15 Project (com.intellij.openapi.project.Project)6 GradleInvocationResult (com.android.tools.idea.gradle.project.build.invoker.GradleInvocationResult)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)2 GradleSyncSummary (com.android.tools.idea.gradle.project.sync.GradleSyncSummary)2 Module (com.intellij.openapi.module.Module)2 NotNull (org.jetbrains.annotations.NotNull)2 SdkConstants (com.android.SdkConstants)1 VisibleForTesting (com.android.annotations.VisibleForTesting)1 AndroidLibrary (com.android.builder.model.AndroidLibrary)1 AndroidProject (com.android.builder.model.AndroidProject)1 Message (com.android.ide.common.blame.Message)1 GradleVersion (com.android.ide.common.repository.GradleVersion)1 ApkProjects.isApkProject (com.android.tools.idea.apk.ApkProjects.isApkProject)1 AndroidPluginGeneration (com.android.tools.idea.gradle.plugin.AndroidPluginGeneration)1 AndroidPluginVersionUpdater (com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater)1 AndroidGradleBuildConfiguration (com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration)1 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)1 NdkFacet (com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)1