private static synchronized void checkOrInstall(@NotNull Project project,
                                                  @Nullable String workingDir,
                                                  @Nullable MavenSyncConsole syncConsole) {
    if (workingDir == null) return;
    MavenDistributionsCache distributionsCache = MavenDistributionsCache.getInstance(project);

    String multiModuleDir = distributionsCache.getMultimoduleDirectory(workingDir);
    String distributionUrl = distributionsCache.getWrapperDistributionUrl(multiModuleDir);
    if (distributionUrl == null) {
      MavenWrapperEventLogNotification.noDistributionUrlEvent(project, multiModuleDir);
      return;
    }

    MavenDistribution distribution = MavenWrapperSupport.getCurrentDistribution(distributionUrl);
    if (distribution != null) return;

    MavenLog.LOG.info("start install wrapper " + distributionUrl);

    if (syncConsole != null) syncConsole.startWrapperResolving();

    Task.Backgroundable task = getTaskInfo();
    BackgroundableProcessIndicator indicator = new WrapperProgressIndicator(project, task, syncConsole);
    try {
      distribution = new MavenWrapperSupport().downloadAndInstallMaven(distributionUrl, indicator);
      if (syncConsole != null && distributionUrl.toLowerCase(Locale.ENGLISH).startsWith("http:")) {
        MavenWrapperSupport.showUnsecureWarning(syncConsole, LocalFileSystem.getInstance().findFileByPath(multiModuleDir));
      }
      distributionsCache.addWrapper(multiModuleDir, distribution);
      if (syncConsole != null) syncConsole.finishWrapperResolving(null);
    }
    catch (Exception e) {
      MavenLog.LOG.warn("error install wrapper", e);
      if (syncConsole != null) syncConsole.finishWrapperResolving(e);
      MavenWrapperEventLogNotification.errorDownloading(project, e.getLocalizedMessage());
      if (syncConsole != null) {
        MavenWorkspaceSettings settings = MavenWorkspaceSettingsComponent.getInstance(project).getSettings();
        settings.getGeneralSettings().setMavenHomeType(BundledMaven3.INSTANCE);
      }
    }
    finally {
      indicator.finish(task);
      MavenLog.LOG.info("finish install wrapper " + distributionUrl);
    }
  }
private static synchronized void checkOrInstall(@NotNull Project project,
                                                  @Nullable String workingDir,
                                                  @Nullable MavenSyncConsole syncConsole)