private void removeProjectRepositoriesThatAreInSettings(
     final Collection<RemoteRepository> projectRepositories,
     final Collection<RemoteRepository> settingsRepositories) {
   final Collection<RemoteRepository> projectRepositoriesToRemove =
       new HashSet<RemoteRepository>();
   final Iterator<RemoteRepository> projectRepositoryItr = projectRepositories.iterator();
   while (projectRepositoryItr.hasNext()) {
     final RemoteRepository projectRepository = projectRepositoryItr.next();
     for (RemoteRepository settingsRepository : settingsRepositories) {
       if (projectRepository.getId().equals(settingsRepository.getId())) {
         if (projectRepository.getUrl().equals(settingsRepository.getUrl())) {
           projectRepositoriesToRemove.add(projectRepository);
         }
       }
     }
   }
   projectRepositories.removeAll(projectRepositoriesToRemove);
 }
 private MavenRepositoryMetadata makeRepositoryMetaData(
     final ArtifactRepository repository, final MavenRepositorySource source) {
   if (repository instanceof LocalRepository) {
     final LocalRepository localRepository = (LocalRepository) repository;
     return new MavenRepositoryMetadata(
         localRepository.getId(), MavenSettings.getSettings().getLocalRepository(), source);
   } else if (repository instanceof RemoteRepository) {
     final RemoteRepository remoteRepository = (RemoteRepository) repository;
     return new MavenRepositoryMetadata(
         remoteRepository.getId(), remoteRepository.getUrl(), source);
   }
   return null;
 }
  /**
   * Creates a model resolver to assist building of dependency POMs.
   *
   * @param system a {@link RepositorySystem}
   * @param session a {@link RepositorySystemSession}
   * @param remoteRepositories remote repositories to use for resolution.
   */
  public SimpleModelResolver(
      RepositorySystem system,
      RepositorySystemSession session,
      List<RemoteRepository> remoteRepositories) {
    this.system = system;
    this.session = session;
    this.repositories = new ArrayList<>(remoteRepositories);
    this.repositoryIds =
        new HashSet<>(remoteRepositories.size() < 3 ? 3 : remoteRepositories.size());

    for (RemoteRepository repository : remoteRepositories) {
      repositoryIds.add(repository.getId());
    }
  }
Esempio n. 4
0
 private Mirror getMirror(RepositorySystemSession session, ArtifactRepository repository) {
   if (session != null) {
     org.eclipse.aether.repository.MirrorSelector selector = session.getMirrorSelector();
     if (selector != null) {
       RemoteRepository repo = selector.getMirror(RepositoryUtils.toRepo(repository));
       if (repo != null) {
         Mirror mirror = new Mirror();
         mirror.setId(repo.getId());
         mirror.setUrl(repo.getUrl());
         mirror.setLayout(repo.getContentType());
         return mirror;
       }
     }
   }
   return null;
 }
  private MirrorDef findMirror(RemoteRepository repository) {
    if (!mirrors.isEmpty()) {
      String repoId = repository.getId();
      String repoType = repository.getContentType();

      for (MirrorDef mirror : mirrors) {
        if (mirror.idMatcher.isExactMatch(repoId) && mirror.typeMatcher.isMatch(repoType)) {
          return mirror;
        }
      }

      for (MirrorDef mirror : mirrors) {
        if (mirror.idMatcher.isMatch(repository) && mirror.typeMatcher.isMatch(repoType)) {
          return mirror;
        }
      }
    }

    return null;
  }
 boolean isMatch(RemoteRepository repository) {
   boolean result = false;
   if (mirrorOfIds.length <= 0) {
     result = false;
   } else {
     String repoId = repository.getId();
     for (String mirrorOfId : mirrorOfIds) {
       if (mirrorOfId.equals(repoId)) {
         result = true;
         break;
       } else if (mirrorOfId.startsWith("!") && mirrorOfId.substring(1).equals(repoId)) {
         result = false;
         break;
       } else if (EXTERNAL_WILDCARD.equals(mirrorOfId) && isExternalRepo(repository)) {
         result = true;
       } else if (WILDCARD.equals(mirrorOfId)) {
         result = true;
       }
     }
   }
   return result;
 }