Search in sources :

Example 36 with RepositorySystemSession

use of org.eclipse.aether.RepositorySystemSession 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)

Example 37 with RepositorySystemSession

use of org.eclipse.aether.RepositorySystemSession in project BIMserver by opensourceBIM.

the class RemotePluginRepository method main.

public static void main(String[] args) throws ArtifactResolutionException {
    System.out.println("------------------------------------------------------------");
    System.out.println(RemotePluginRepository.class.getSimpleName());
    RepositorySystem system = newRepositorySystem();
    RepositorySystemSession session = newRepositorySystemSession(system);
    Artifact artifact = new DefaultArtifact("org.eclipse.aether:aether-util:1.0.0.v20140518");
    ArtifactRequest artifactRequest = new ArtifactRequest();
    artifactRequest.setArtifact(artifact);
    artifactRequest.setRepositories(newRepositories(system, session));
    ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
    artifact = artifactResult.getArtifact();
    System.out.println(artifact + " resolved to  " + artifact.getFile());
}
Also used : RepositorySystem(org.eclipse.aether.RepositorySystem) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Example 38 with RepositorySystemSession

use of org.eclipse.aether.RepositorySystemSession in project karaf by apache.

the class DependencyHelperFactory method createDependencyHelper.

/**
 * Create a new {@link DependencyHelper} based on what has been found in
 * {@link org.codehaus.plexus.PlexusContainer}.
 *
 * @param container    The Maven Plexus container to use.
 * @param mavenProject The Maven project to use.
 * @param mavenSession The Maven session.
 * @param cacheSize    Size of the artifact/file LRU cache
 * @param log          The log to use for the messages.
 *
 * @return The {@link DependencyHelper} depending of the Maven version used.
 *
 * @throws MojoExecutionException If the plugin execution fails.
 */
public static DependencyHelper createDependencyHelper(PlexusContainer container, MavenProject mavenProject, MavenSession mavenSession, int cacheSize, Log log) throws MojoExecutionException {
    try {
        final RepositorySystem system = container.lookup(RepositorySystem.class);
        final RepositorySystemSession session = mavenSession.getRepositorySession();
        final List<RemoteRepository> repositories = mavenProject.getRemoteProjectRepositories();
        return new Dependency31Helper(repositories, session, system, cacheSize);
    } catch (ComponentLookupException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}
Also used : RepositorySystem(org.eclipse.aether.RepositorySystem) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException)

Aggregations

RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)38 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)19 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)14 RepositorySystem (org.eclipse.aether.RepositorySystem)13 Artifact (org.eclipse.aether.artifact.Artifact)13 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)13 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)12 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)11 ArrayList (java.util.ArrayList)10 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)10 File (java.io.File)8 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)7 List (java.util.List)5 Artifact (org.apache.maven.artifact.Artifact)5 MavenSession (org.apache.maven.execution.MavenSession)5 IOException (java.io.IOException)4 DefaultMaven (org.apache.maven.DefaultMaven)4 Maven (org.apache.maven.Maven)4 InvalidRepositoryException (org.apache.maven.artifact.InvalidRepositoryException)4 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)4