@NotNull
  @NlsSafe
  public static String resolveMavenHome(@NotNull MavenGeneralSettings coreSettings,
                                        @NotNull Project project,
                                        @NotNull String workingDir, @Nullable MavenRunConfiguration runConfiguration)
    throws ExecutionException {
    MavenHomeType type = coreSettings.getMavenHomeType();
    File file = null;
    if (type instanceof StaticResolvedMavenHomeType st) {
      file = MavenUtil.getMavenHomeFile(st);
    }
    if (type instanceof MavenWrapper) {
      MavenDistribution distribution = MavenDistributionsCache.getInstance(project).getWrapper(workingDir);
      if (distribution != null) {
        file = distribution.getMavenHome().toFile();
      } else {
        file = MavenDistributionsCache.resolveEmbeddedMavenHome().getMavenHome().toFile();
      }
    }

    if (file == null) {
      throw createExecutionException(RunnerBundle.message("external.maven.home.no.default"),
                                     RunnerBundle.message("external.maven.home.no.default.with.fix"),
                                     coreSettings, project, runConfiguration);
    }

    if (!file.exists()) {
      throw createExecutionException(RunnerBundle.message("external.maven.home.does.not.exist", file.getPath()),
                                     RunnerBundle.message("external.maven.home.does.not.exist.with.fix", file.getPath()),
                                     coreSettings, project, runConfiguration);
    }

    if (!MavenUtil.isValidMavenHome(file)) {
      throw createExecutionException(RunnerBundle.message("external.maven.home.invalid", file.getPath()),
                                     RunnerBundle.message("external.maven.home.invalid.with.fix", file.getPath()),
                                     coreSettings, project, runConfiguration);
    }

    try {
      return file.getCanonicalPath();
    }
    catch (IOException e) {
      throw new ExecutionException(e.getMessage(), e);
    }
  }
@NotNull
  @NlsSafe
  public static String resolveMavenHome(@NotNull MavenGeneralSettings coreSettings,
                                        @NotNull Project project,
                                        @NotNull String workingDir, @Nullable MavenRunConfiguration runConfiguration)