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);
}
Aggregations