@NotNull
  @Override
  public Function<Pair<Project, String>, GradleExecutionSettings> getExecutionSettingsProvider() {
    return pair -> {
      Project project = pair.first;
      String projectPath = pair.second;
      GradleSettings settings = GradleSettings.getInstance(project);
      GradleProjectSettings projectLevelSettings = settings.getLinkedProjectSettings(projectPath);
      String rootProjectPath = projectLevelSettings != null ? projectLevelSettings.getExternalProjectPath() : projectPath;

      GradleInstallationManager gradleInstallationManager = GradleInstallationManager.getInstance();
      File gradleHome = gradleInstallationManager.getGradleHome(project, rootProjectPath);
      String localGradlePath = null;
      if (gradleHome != null) {
        try {
          // Try to resolve symbolic links as there were problems with them at the gradle side.
          localGradlePath = gradleHome.getCanonicalPath();
        }
        catch (IOException e) {
          localGradlePath = gradleHome.getAbsolutePath();
        }
      }

      final DistributionType distributionType;
      if (projectLevelSettings == null) {
        distributionType =
          GradleUtil.isGradleDefaultWrapperFilesExist(rootProjectPath) ? DistributionType.DEFAULT_WRAPPED : DistributionType.BUNDLED;
      }
      else {
        distributionType =
          projectLevelSettings.getDistributionType() == null ? DistributionType.LOCAL : projectLevelSettings.getDistributionType();
      }

      GradleExecutionSettings result = new GradleExecutionSettings(localGradlePath,
                                                                   settings.getServiceDirectoryPath(),
                                                                   distributionType,
                                                                   settings.getGradleVmOptions(),
                                                                   settings.isOfflineWork());
      String javaHome = gradleInstallationManager.getGradleJvmPath(project, rootProjectPath);
      if (!StringUtil.isEmpty(javaHome)) {
        LOG.info("Instructing gradle to use java from " + javaHome);
      }
      result.setJavaHome(javaHome);
      GradleSystemSettings systemSettings = GradleSystemSettings.getInstance();
      String vmOptions = Objects.requireNonNullElse(settings.getGradleVmOptions(), "");
      if (vmOptions.contains("-Didea.gradle.download.sources.force=false")) {
        result.setDownloadSources(false);
      } else {
        result.setDownloadSources(systemSettings.isDownloadSources());
      }
      result.setParallelModelFetch(settings.isParallelModelFetch());
      String ideProjectPath;
      if (project.getBasePath() == null ||
          (project.getProjectFilePath() != null && StringUtil.endsWith(project.getProjectFilePath(), ".ipr"))) {
        ideProjectPath = rootProjectPath;
      }
      else {
        ideProjectPath = project.getBasePath() + "/.idea/modules";
      }
      result.setIdeProjectPath(ideProjectPath);
      if (projectLevelSettings != null) {
        result.setResolveModulePerSourceSet(projectLevelSettings.isResolveModulePerSourceSet());
        result.setUseQualifiedModuleNames(projectLevelSettings.isUseQualifiedModuleNames());
      }
      boolean delegatedBuildEnabled = GradleProjectSettings.isDelegatedBuildEnabled(project, projectPath);
      result.setDelegatedBuild(delegatedBuildEnabled);

      configureExecutionWorkspace(projectLevelSettings, settings, result, project, projectPath);
      return result;
    };
  }
@NotNull
  @Override
  public Function<Pair<Project, String>, GradleExecutionSettings> getExecutionSettingsProvider()