public static JavaParameters createJavaParameters(@NotNull final Project project,
                                                    @NotNull final MavenRunnerParameters parameters,
                                                    @Nullable MavenGeneralSettings coreSettings,
                                                    @Nullable MavenRunnerSettings runnerSettings,
                                                    @Nullable MavenRunConfiguration runConfiguration) throws ExecutionException {
    final JavaParameters params = new JavaParameters();


    if (coreSettings == null) {
      coreSettings = MavenProjectsManager.getInstance(project).getGeneralSettings();
    }
    final String mavenHome = resolveMavenHome(coreSettings, project, parameters.getWorkingDirPath(), runConfiguration);
    final String mavenVersion = MavenUtil.getMavenVersion(mavenHome);
    if (mavenVersion == null) {
      throw new ExecutionException(MavenProjectBundle.message("dialog.message.maven.home.directory.invalid", mavenHome));
    }

    if (runnerSettings == null) {
      runnerSettings = MavenRunner.getInstance(project).getState();
    }
    params.getProgramParametersList().patchMacroWithEnvs(runnerSettings.getEnvironmentProperties());

    params.setWorkingDirectory(expandPathAndMacros(parameters.getWorkingDirPath(), null, project));


    String jreName = runnerSettings.getJreName();
    boolean isGlobalRunnerSettings = MavenRunner.getInstance(project).getState() == runnerSettings;
    Sdk jdk = ReadAction.compute(()->getJdk(project, jreName, isGlobalRunnerSettings ));
    params.setJdk(jdk);

    if(!verifyMavenSdkRequirements(jdk, mavenVersion)){
      throw new ExecutionException(RunnerBundle.message("maven.3.3.1.bad.jdk"));
    }

    params.getProgramParametersList().addProperty("idea.version", MavenUtil.getIdeaVersionToPassToMavenProcess());
    if (StringUtil.compareVersionNumbers(mavenVersion, "3.3") >= 0) {
      String mavenMultimoduleDir;

      if (!StringUtil.isEmptyOrSpaces(parameters.getMultimoduleDir())) {
        mavenMultimoduleDir = expandPathAndMacros(parameters.getMultimoduleDir(), null, project);
      }
      else {
        mavenMultimoduleDir = MavenServerUtil.findMavenBasedir(parameters.getWorkingDirFile()).getPath();
      }


      params.getVMParametersList().addProperty("maven.multiModuleProjectDirectory", mavenMultimoduleDir);
    }

    if (StringUtil.compareVersionNumbers(mavenVersion, "3.5") >= 0) {
      params.getVMParametersList().addProperty("jansi.passthrough", "true");
    }

    String vmOptions = getRunVmOptions(runnerSettings, project, parameters.getWorkingDirPath());
    vmOptions = expandPathAndMacros(vmOptions, null, project);
    addVMParameters(params.getVMParametersList(), mavenHome, vmOptions);

    File confFile = MavenUtil.getMavenConfFile(new File(mavenHome));
    if (!confFile.isFile()) {
      throw new ExecutionException(
        MavenProjectBundle.message("dialog.message.configuration.file.not.exists.in.maven.home", confFile.getAbsolutePath()));
    }

    if (parameters.isResolveToWorkspace()) {
      try {
        String resolverJar = getArtifactResolverJar(mavenVersion);
        confFile = patchConfFile(confFile, resolverJar);

        File modulesPathsFile = dumpModulesPaths(project);
        params.getVMParametersList().addProperty(MavenModuleMap.PATHS_FILE_PROPERTY, modulesPathsFile.getAbsolutePath());
      }
      catch (IOException e) {
        LOG.error(e);
        throw new ExecutionException(MavenProjectBundle.message("dialog.message.failed.to.run.maven.configuration"), e);
      }
    }

    params.getVMParametersList().addProperty("classworlds.conf", confFile.getPath());

    for (String path : getMavenClasspathEntries(mavenHome)) {
      params.getClassPath().add(path);
    }

    params.setEnv(new HashMap<>(runnerSettings.getEnvironmentProperties()));
    params.setPassParentEnvs(runnerSettings.isPassParentEnv());

    params.setMainClass(MAVEN_LAUNCHER_CLASS);
    EncodingManager encodingManager = EncodingProjectManager.getInstance(project);
    params.setCharset(encodingManager.getDefaultCharset());

    addMavenParameters(params.getProgramParametersList(), mavenHome, coreSettings, runnerSettings, parameters);
    MavenUtil.addEventListener(mavenVersion, params);

    return params;
  }
public static JavaParameters createJavaParameters(@NotNull final Project project,
                                                    @NotNull final MavenRunnerParameters parameters,
                                                    @Nullable MavenGeneralSettings coreSettings,
                                                    @Nullable MavenRunnerSettings runnerSettings,
                                                    @Nullable MavenRunConfiguration runConfiguration)