private static synchronized ArtifactRepositoryManager getRepositoryManager(final CompileContext context, @Nullable String remoteRepositoryId)
    throws RemoteRepositoryNotFoundException {
    
    Pair<ArtifactRepositoryManager, Map<String, ArtifactRepositoryManager>> managers = MANAGERS_KEY.get(context);
    if (managers == null) {
      Map<String, JpsMavenSettings.RemoteRepositoryAuthentication> mavenSettingsXmlAuth = JpsMavenSettings.loadAuthenticationSettings(
        JpsMavenSettings.getGlobalMavenSettingsXml(),
        JpsMavenSettings.getUserMavenSettingsXml()
      );
      final List<RemoteRepository> repositories = new SmartList<>();
      for (JpsRemoteRepositoryDescription repo : JpsRemoteRepositoryService.getInstance().getOrCreateRemoteRepositoriesConfiguration(context.getProjectDescriptor().getProject())
          .getRepositories()) {
        ArtifactAuthenticationData authenticationData = obtainRemoteRepositoryAuthenticationData(repo, mavenSettingsXmlAuth);
        repositories.add(ArtifactRepositoryManager.createRemoteRepository(repo.getId(), repo.getUrl(), authenticationData));
      }
      Retry retry = RetryProvider.disabled();
      if (SystemProperties.getBooleanProperty(RESOLUTION_RETRY_ENABLED_PROPERTY, false)) {
        long retryInitialDelay = SystemProperties.getLongProperty(RESOLUTION_RETRY_DELAY_MS_PROPERTY, 1000);
        long retryBackoffLimit = SystemProperties.getLongProperty(RESOLUTION_RETRY_BACKOFF_LIMIT_MS_PROPERTY, TimeUnit.MINUTES.toMillis(15));
        int retryMaxAttempts = SystemProperties.getIntProperty(RESOLUTION_RETRY_MAX_ATTEMPTS_PROPERTY, 10);
        retry = RetryProvider.withExponentialBackOff(retryInitialDelay, retryBackoffLimit, retryMaxAttempts);
      }

      File localRepositoryRoot = getLocalArtifactRepositoryRoot(context.getProjectDescriptor().getModel().getGlobal());

      ProgressConsumer progressConsumer = new ProgressConsumer() {
        @Override
        public void consume(@NlsSafe String message) {
          context.processMessage(new ProgressMessage(message));
        }

        @Override
        public boolean isCanceled() {
          return context.getCancelStatus().isCanceled();
        }
      };

      final ArtifactRepositoryManager unnamedManager = new ArtifactRepositoryManager(localRepositoryRoot, repositories, progressConsumer, retry);
      // further init manager here
      
      final Map<String, ArtifactRepositoryManager> namedManagers = new HashMap<>();
      for (RemoteRepository repository : repositories) {
        namedManagers.put(repository.getId(), new ArtifactRepositoryManager(localRepositoryRoot, Collections.singletonList(repository), progressConsumer, retry));
      }

      MANAGERS_KEY.set(context, managers = Pair.create(unnamedManager, Collections.unmodifiableMap(namedManagers)));
    }

    if (remoteRepositoryId == null) {
      return managers.getFirst();
    }
    final ArtifactRepositoryManager namedManager = managers.getSecond().get(remoteRepositoryId);
    if (namedManager == null) {
      throw new RemoteRepositoryNotFoundException(
        JpsBuildBundle.message("build.message.error.bind.repository.id.not.found", remoteRepositoryId)
      );
    }
    return namedManager;
  }
private static synchronized ArtifactRepositoryManager getRepositoryManager(final CompileContext context, @Nullable String remoteRepositoryId)