Search in sources :

Example 1 with GradleProjectSyncData

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

the class IdeaGradleSync method sync.

@Override
public void sync(@NotNull Project project, @NotNull GradleSyncInvoker.Request request, @Nullable GradleSyncListener listener) {
    // Prevent IDEA from syncing with Gradle. We want to have full control of syncing.
    project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, true);
    if (SYNC_WITH_CACHED_MODEL_ONLY || request.isUseCachedGradleModels()) {
        GradleProjectSyncData syncData = GradleProjectSyncData.getInstance((project));
        if (syncData != null && syncData.canUseCachedProjectData()) {
            DataNodeCaches dataNodeCaches = DataNodeCaches.getInstance(project);
            DataNode<ProjectData> cache = dataNodeCaches.getCachedProjectData();
            if (cache != null && !dataNodeCaches.isCacheMissingModels(cache)) {
                PostSyncProjectSetup.Request setupRequest = new PostSyncProjectSetup.Request();
                // @formatter:off
                setupRequest.setUsingCachedGradleModels(true).setGenerateSourcesAfterSync(false).setLastSyncTimestamp(syncData.getLastGradleSyncTimestamp());
                // @formatter:on
                boolean newProject = request.isNewProject();
                ProjectSetUpTask setUpTask = new ProjectSetUpTask(project, setupRequest, listener, newProject, !newProject, true);
                setUpTask.onSuccess(cache);
                return;
            }
        }
    }
    PostSyncProjectSetup.Request setupRequest = new PostSyncProjectSetup.Request();
    // @formatter:off
    setupRequest.setGenerateSourcesAfterSync(request.isGenerateSourcesOnSuccess()).setCleanProjectAfterSync(request.isCleanProject());
    // @formatter:on
    String externalProjectPath = getBaseDirPath(project).getPath();
    ProjectSetUpTask setUpTask = new ProjectSetUpTask(project, setupRequest, listener, request.isNewProject(), false, false);
    ProgressExecutionMode executionMode = request.getProgressExecutionMode();
    refreshProject(project, GRADLE_SYSTEM_ID, externalProjectPath, setUpTask, false, /* resolve dependencies */
    executionMode, true);
}
Also used : GradleProjectSyncData(com.android.tools.idea.gradle.project.GradleProjectSyncData) PostSyncProjectSetup(com.android.tools.idea.gradle.project.sync.setup.post.PostSyncProjectSetup) DataNodeCaches(com.android.tools.idea.gradle.project.sync.idea.data.DataNodeCaches) ProgressExecutionMode(com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Aggregations

GradleProjectSyncData (com.android.tools.idea.gradle.project.GradleProjectSyncData)1 DataNodeCaches (com.android.tools.idea.gradle.project.sync.idea.data.DataNodeCaches)1 PostSyncProjectSetup (com.android.tools.idea.gradle.project.sync.setup.post.PostSyncProjectSetup)1 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)1 ProgressExecutionMode (com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode)1