Search in sources :

Example 1 with RepositorySystemSessionProvider

use of io.tesla.aether.guice.RepositorySystemSessionProvider in project druid by druid-io.

the class PullDependencies method createTeslaAether.

private DefaultTeslaAether createTeslaAether(List<Repository> remoteRepositories) {
    if (!useProxy) {
        return new DefaultTeslaAether(localRepository, remoteRepositories.toArray(new Repository[0]));
    }
    if (!StringUtils.toLowerCase(proxyType).equals(Proxy.TYPE_HTTP) && !StringUtils.toLowerCase(proxyType).equals(Proxy.TYPE_HTTPS)) {
        throw new IllegalArgumentException("invalid proxy type: " + proxyType);
    }
    RepositorySystemSession repositorySystemSession = new RepositorySystemSessionProvider(new File(localRepository)).get();
    List<RemoteRepository> rl = remoteRepositories.stream().map(r -> {
        RemoteRepository.Builder builder = new RemoteRepository.Builder(r.getId(), "default", r.getUrl());
        if (r.getUsername() != null && r.getPassword() != null) {
            Authentication auth = new AuthenticationBuilder().addUsername(r.getUsername()).addPassword(r.getPassword()).build();
            builder.setAuthentication(auth);
        }
        final Authentication proxyAuth;
        if (Strings.isNullOrEmpty(proxyUsername)) {
            proxyAuth = null;
        } else {
            proxyAuth = new AuthenticationBuilder().addUsername(proxyUsername).addPassword(proxyPassword).build();
        }
        builder.setProxy(new Proxy(proxyType, proxyHost, proxyPort, proxyAuth));
        return builder.build();
    }).collect(Collectors.toList());
    return new DefaultTeslaAether(rl, repositorySystemSession);
}
Also used : Option(com.github.rvesse.airline.annotations.Option) Logger(org.apache.druid.java.util.common.logger.Logger) TeslaAether(io.tesla.aether.TeslaAether) TaskConfig(org.apache.druid.indexing.common.config.TaskConfig) DependencyFilterUtils(org.eclipse.aether.util.filter.DependencyFilterUtils) Proxy(org.eclipse.aether.repository.Proxy) Inject(com.google.inject.Inject) URISyntaxException(java.net.URISyntaxException) Dependency(org.eclipse.aether.graph.Dependency) JavaScopes(org.eclipse.aether.util.artifact.JavaScopes) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) ImmutableList(com.google.common.collect.ImmutableList) ExtensionsConfig(org.apache.druid.guice.ExtensionsConfig) URI(java.net.URI) Repository(io.tesla.aether.Repository) Command(com.github.rvesse.airline.annotations.Command) FileUtils(org.apache.druid.java.util.common.FileUtils) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) CollectRequest(org.eclipse.aether.collection.CollectRequest) OutputStream(java.io.OutputStream) PrintStream(java.io.PrintStream) RepositorySystemSessionProvider(io.tesla.aether.guice.RepositorySystemSessionProvider) DependencyNode(org.eclipse.aether.graph.DependencyNode) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) StringUtils(org.apache.druid.java.util.common.StringUtils) Artifact(org.eclipse.aether.artifact.Artifact) Set(java.util.Set) ISE(org.apache.druid.java.util.common.ISE) IOException(java.io.IOException) SuppressForbidden(io.netty.util.SuppressForbidden) DependencyRequest(org.eclipse.aether.resolution.DependencyRequest) Collectors(java.util.stream.Collectors) SetMultimap(com.google.common.collect.SetMultimap) File(java.io.File) Authentication(org.eclipse.aether.repository.Authentication) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) List(java.util.List) VisibleForTesting(com.google.common.annotations.VisibleForTesting) DefaultTeslaAether(io.tesla.aether.internal.DefaultTeslaAether) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) DefaultTeslaAether(io.tesla.aether.internal.DefaultTeslaAether) RepositorySystemSessionProvider(io.tesla.aether.guice.RepositorySystemSessionProvider) Repository(io.tesla.aether.Repository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Proxy(org.eclipse.aether.repository.Proxy) Authentication(org.eclipse.aether.repository.Authentication) File(java.io.File)

Aggregations

Command (com.github.rvesse.airline.annotations.Command)1 Option (com.github.rvesse.airline.annotations.Option)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)1 SetMultimap (com.google.common.collect.SetMultimap)1 Inject (com.google.inject.Inject)1 SuppressForbidden (io.netty.util.SuppressForbidden)1 Repository (io.tesla.aether.Repository)1 TeslaAether (io.tesla.aether.TeslaAether)1 RepositorySystemSessionProvider (io.tesla.aether.guice.RepositorySystemSessionProvider)1 DefaultTeslaAether (io.tesla.aether.internal.DefaultTeslaAether)1 File (java.io.File)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1