private void addEntireP2RepositoryToTargetPlatform(
      ArtifactRepository repository,
      TargetPlatformBuilder resolutionContext,
      MavenSession session) {
    try {
      URI uri = new URL(repository.getUrl()).toURI();

      if (repository.getLayout() instanceof P2ArtifactRepositoryLayout) {
        if (session.isOffline()) {
          getLogger()
              .debug(
                  "Offline mode, using local cache only for repository "
                      + repository.getId()
                      + " ("
                      + repository.getUrl()
                      + ")");
        }

        try {
          Authentication auth = repository.getAuthentication();
          if (auth != null) {
            resolutionContext.setCredentials(uri, auth.getUsername(), auth.getPassword());
          }

          resolutionContext.addP2Repository(uri);

          getLogger()
              .debug(
                  "Added p2 repository " + repository.getId() + " (" + repository.getUrl() + ")");
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    } catch (MalformedURLException e) {
      getLogger().warn("Could not parse repository URL", e);
    } catch (URISyntaxException e) {
      getLogger().warn("Could not parse repository URL", e);
    }
  }
Beispiel #2
0
 private Authentication getAuthentication(
     RepositorySystemSession session, ArtifactRepository repository) {
   if (session != null) {
     AuthenticationSelector selector = session.getAuthenticationSelector();
     if (selector != null) {
       RemoteRepository repo = RepositoryUtils.toRepo(repository);
       org.eclipse.aether.repository.Authentication auth = selector.getAuthentication(repo);
       if (auth != null) {
         repo = new RemoteRepository.Builder(repo).setAuthentication(auth).build();
         AuthenticationContext authCtx = AuthenticationContext.forRepository(session, repo);
         Authentication result =
             new Authentication(
                 authCtx.get(AuthenticationContext.USERNAME),
                 authCtx.get(AuthenticationContext.PASSWORD));
         result.setPrivateKey(authCtx.get(AuthenticationContext.PRIVATE_KEY_PATH));
         result.setPassphrase(authCtx.get(AuthenticationContext.PRIVATE_KEY_PASSPHRASE));
         authCtx.close();
         return result;
       }
     }
   }
   return null;
 }