void (@NotNull RunnerAndConfigurationSettings configuration, @NotNull Executor executor, @Nullable ExecutionTarget targetOrNullForDefault, @Nullable Long executionId, @Nullable DataContext dataContext, @Nullable Consumer<? super ExecutionEnvironment> environmentCustomization) { ExecutionEnvironmentBuilder builder = createEnvironment(executor, configuration); if (builder == null) { return; } if (targetOrNullForDefault != null) { builder.target(targetOrNullForDefault); } else { builder.activeTarget(); } if (executionId != null) { builder.executionId(executionId); } if (dataContext != null) { builder.dataContext(IdeUiService.getInstance().createAsyncDataContext(dataContext)); } ExecutionEnvironment environment = ApplicationManager.getApplication().isDispatchThread() ? ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ReadAction.compute(() -> builder.build()), ExecutionBundle.message("dialog.title.preparing.execution"), true, null) : builder.build(); if(environmentCustomization != null) { environmentCustomization.accept(environment); } ExecutionManager.getInstance(configuration.getConfiguration().getProject()).restartRunProfile(environment); }