public static void runTask(@NotNull TaskExecutionSpec spec) {
    Project project = spec.getProject();
    ProjectSystemId externalSystemId = spec.getSystemId();

    var environment = createExecutionEnvironment(project, externalSystemId, spec.getSettings(), spec.getExecutorId());
    if (environment == null) {
      LOG.warn("Execution environment for " + externalSystemId + " is null");
      return;
    }

    var runnerAndConfigurationSettings = environment.getRunnerAndConfigurationSettings();
    assert runnerAndConfigurationSettings != null;
    runnerAndConfigurationSettings.setActivateToolWindowBeforeRun(spec.getActivateToolWindowBeforeRun());

    UserDataHolderBase userData = spec.getUserData();
    if (userData != null) {
      var runConfiguration = (ExternalSystemRunConfiguration)runnerAndConfigurationSettings.getConfiguration();
      userData.copyUserDataTo(runConfiguration);
    }

    var title = AbstractExternalSystemTaskConfigurationType.generateName(project, spec.getSettings());
    ExternalSystemTaskUnderProgress.executeTaskUnderProgress(project, title, spec.getProgressExecutionMode(),
                                                             new ExternalSystemTaskUnderProgress() {
      @Override
      public void execute(@NotNull ProgressIndicator indicator) {
        environment.putUserData(ExternalSystemRunnableState.PROGRESS_INDICATOR_KEY, indicator);
        environment.putUserData(ExternalSystemRunnableState.TASK_NOTIFICATION_LISTENER_KEY, spec.getListener());
        indicator.setIndeterminate(true);

        boolean result = waitForProcessExecution(project, environment, () -> environment.getRunner().execute(environment));
        TaskCallback callback = spec.getCallback();
        if (callback != null) {
          if (result) {
            callback.onSuccess();
          }
          else {
            callback.onFailure();
          }
        }
        if (!result && spec.getActivateToolWindowOnFailure()) {
          ApplicationManager.getApplication().invokeLater(() -> {
            var window = ToolWindowManager.getInstance(project).getToolWindow(environment.getExecutor().getToolWindowId());
            if (window != null) {
              window.activate(null, false, false);
            }
          }, project.getDisposed());
        }
      }
    });
  }
public static void runTask(@NotNull TaskExecutionSpec spec)