@NotNull
  // used in third-party plugins
  public static MavenTaskHandler runInBackground(@NotNull Project project,
                                                 @NotNull @NlsContexts.Command String title,
                                                 boolean cancellable,
                                                 @NotNull MavenTask task) {
    MavenProjectsManager manager = MavenProjectsManager.getInstanceIfCreated(project);
    Supplier<MavenSyncConsole> syncConsoleSupplier = manager == null ? null : () -> manager.getSyncConsole();
    MavenProgressIndicator indicator = new MavenProgressIndicator(project, syncConsoleSupplier);

    Runnable runnable = () -> {
      if (project.isDisposed()) return;

      try {
        task.run(indicator);
      }
      catch (MavenProcessCanceledException | ProcessCanceledException e) {
        indicator.cancel();
      }
    };

    Future<?> future;
    future = ApplicationManager.getApplication().executeOnPooledThread(runnable);
    MavenTaskHandler handler = new MavenTaskHandler() {
      @Override
      public void waitFor() {
        try {
          future.get();
        }
        catch (InterruptedException | ExecutionException e) {
          MavenLog.LOG.error(e);
        }
      }
    };
    invokeLater(project, () -> {
      if (future.isDone()) return;
      new Task.Backgroundable(project, title, cancellable) {
        @Override
        public void run(@NotNull ProgressIndicator i) {
          indicator.setIndicator(i);
          handler.waitFor();
        }
      }.queue();
    });
    return handler;
  }
@NotNull
  // used in third-party plugins
  public static MavenTaskHandler runInBackground(@NotNull Project project,
                                                 @NotNull @NlsContexts.Command String title,
                                                 boolean cancellable,
                                                 @NotNull MavenTask task)