Promise<Void> (@NotNull Project project, @NotNull PlaybackContext context, @NotNull GradleSettings gradleSettings) { if (gradleSettings.getLinkedProjectsSettings().isEmpty()) { VirtualFile projectDir = ProjectUtil.guessProjectDir(project); assert projectDir != null; VirtualFile[] children = projectDir.getChildren(); boolean isGradleProject = ContainerUtil.exists(children, file -> GradleConstants.KNOWN_GRADLE_FILES.contains(file.getName())); if (!isGradleProject) { context.error("Unable to find Gradle project at " + projectDir.getPath(), getLine()); context.message("Files found at the path: " + Arrays.toString(ContainerUtil.map2Array(children, VirtualFile::getName)), getLine()); return Promises.rejectedPromise(); } else { GradleProjectSettings projectSettings = GradleDefaultProjectSettings.createProjectSettings(projectDir.getPath()); GradleProjectImportUtil.setupGradleSettings(gradleSettings); GradleVersion gradleVersion = suggestGradleVersion( new SuggestGradleVersionOptions() .withProject(project) .withProjectJdkVersionFilter(project) ); if (gradleVersion != null) { GradleJvmResolutionUtil.setupGradleJvm(project, projectSettings, gradleVersion); GradleJvmValidationUtil.validateJavaHome(project, projectDir.toNioPath(), gradleVersion); } AsyncPromise<Void> promise = new AsyncPromise<>(); ApplicationManager.getApplication().invokeLater(() -> { gradleSettings.linkProject(projectSettings); promise.setResult(null); }); return promise; } } return Promises.resolvedPromise(); }