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);
    }
  }