Search in sources :

Example 1 with DefaultProxySelector

use of org.sonatype.aether.util.repository.DefaultProxySelector in project gradle by gradle.

the class MavenDeployAction method createRepository.

private org.sonatype.aether.repository.RemoteRepository createRepository(RemoteRepository gradleRepo) {
    org.sonatype.aether.repository.RemoteRepository repo = new org.sonatype.aether.repository.RemoteRepository("remote", gradleRepo.getLayout(), gradleRepo.getUrl());
    org.apache.maven.artifact.ant.Authentication auth = gradleRepo.getAuthentication();
    if (auth != null) {
        repo.setAuthentication(new Authentication(auth.getUserName(), auth.getPassword(), auth.getPrivateKey(), auth.getPassphrase()));
    }
    org.apache.maven.artifact.ant.Proxy proxy = gradleRepo.getProxy();
    if (proxy != null) {
        DefaultProxySelector proxySelector = new DefaultProxySelector();
        Authentication proxyAuth = new Authentication(proxy.getUserName(), proxy.getPassword());
        proxySelector.add(new Proxy(proxy.getType(), proxy.getHost(), proxy.getPort(), proxyAuth), proxy.getNonProxyHosts());
        repo.setProxy(proxySelector.getProxy(repo));
    }
    return repo;
}
Also used : DefaultProxySelector(org.sonatype.aether.util.repository.DefaultProxySelector) RemoteRepository(org.apache.maven.artifact.ant.RemoteRepository) Proxy(org.sonatype.aether.repository.Proxy) Authentication(org.sonatype.aether.repository.Authentication)

Aggregations

RemoteRepository (org.apache.maven.artifact.ant.RemoteRepository)1 Authentication (org.sonatype.aether.repository.Authentication)1 Proxy (org.sonatype.aether.repository.Proxy)1 DefaultProxySelector (org.sonatype.aether.util.repository.DefaultProxySelector)1