void (@Nullable DataNode<ProjectData> externalProject) { assert externalProject != null; context.message("Gradle resolve finished for: " + externalProject.getData().getLinkedExternalProjectPath(), getLine()); SimpleMessageBusConnection connection = project.getMessageBus().simpleConnect(); connection.subscribe(ProjectDataImportListener.TOPIC, new ProjectDataImportListener() { @Override public void onFinalTasksFinished(String projectPath) { _onImportFinished(projectPath); } @Override public void onImportFailed(String projectPath, @NotNull Throwable failure) { _onImportFinished(projectPath); } private void _onImportFinished(String projectPath) { if (!projectsPaths.contains(projectPath)) return; connection.disconnect(); if (gradleProjectsToRefreshCount.decrementAndGet() == 0) { ApplicationManager.getApplication().invokeLater(() -> promise.setResult(null)); } } }); defaultCallback.onSuccess(externalProject); callback.setDone(); }