void (@NotNull PlaybackContext context, @NotNull ActionCallback callback) { Project project = context.getProject(); ExternalSystemProjectTrackerSettings projectTrackerSettings = ExternalSystemProjectTrackerSettings.getInstance(project); ExternalSystemProjectTrackerSettings.AutoReloadType currentAutoReloadType = projectTrackerSettings.getAutoReloadType(); projectTrackerSettings.setAutoReloadType(ExternalSystemProjectTrackerSettings.AutoReloadType.NONE); context.message("Waiting for open and initialized Gradle project", getLine()); ExternalProjectsManagerImpl.getInstance(project).runWhenInitialized(() -> DumbService.getInstance(project).runWhenSmart(() -> { ApplicationManager.getApplication().executeOnPooledThread(() -> { waitForCurrentResolveTasks(context, project) .thenAsync(o -> { context.message("Import of the project has been started", getLine()); AsyncPromise<Void> promise = new AsyncPromise<>(); GradleSettings gradleSettings = GradleSettings.getInstance(project); linkGradleProjectIfNeeded(project, context, gradleSettings) .onError(throwable -> callback.reject("Link of a gradle project failed. Not a gradle project")) .onSuccess(unused -> doGradleSync(project, context, promise, gradleSettings, callback)); return promise; }) .onProcessed(promise -> { context.message("Import has been finished", getLine()); projectTrackerSettings.setAutoReloadType(currentAutoReloadType); DumbService.getInstance(project).runWhenSmart(DisposeAwareRunnable.create(() -> callback.setDone(), project)); }); }); })); }