enable proxy support for all types of remote repositories

This commit is contained in:
Sebastian Sdorra
2012-04-19 17:02:55 +02:00
parent 945dbba396
commit 7d42bc9491
2 changed files with 140 additions and 26 deletions

View File

@@ -53,7 +53,6 @@ import org.sonatype.aether.impl.ArtifactDescriptorReader;
import org.sonatype.aether.impl.VersionRangeResolver;
import org.sonatype.aether.impl.VersionResolver;
import org.sonatype.aether.impl.internal.DefaultServiceLocator;
import org.sonatype.aether.repository.Authentication;
import org.sonatype.aether.repository.LocalRepository;
import org.sonatype.aether.repository.Proxy;
import org.sonatype.aether.repository.RemoteRepository;
@@ -217,12 +216,12 @@ public class AetherPluginHandler
if (configuration.isEnableProxy())
{
Proxy proxy = createProxy();
Proxy proxy = DefaultProxySelector.createProxy(configuration);
if (logger.isDebugEnabled())
{
logger.debug("enable proxy {} for {}", repository.getUrl(),
proxy.getHost());
logger.debug("enable proxy {} for {}", proxy.getHost(),
repository.getUrl());
}
rr.setProxy(proxy);
@@ -248,6 +247,16 @@ public class AetherPluginHandler
remoteRepositories);
MavenRepositorySystemSession session = new MavenRepositorySystemSession();
if (configuration.isEnableProxy())
{
if (logger.isDebugEnabled())
{
logger.debug("enable proxy selector to collect dependencies");
}
session.setProxySelector(new DefaultProxySelector(configuration));
}
session.setLocalRepositoryManager(
repositorySystem.newLocalRepositoryManager(localRepository));
@@ -315,28 +324,6 @@ public class AetherPluginHandler
return classpathSet;
}
/**
* Method description
*
*
* @return
*/
private Proxy createProxy()
{
Authentication authentication = null;
String username = configuration.getProxyUser();
String password = configuration.getProxyPassword();
if (Util.isNotEmpty(username) || Util.isNotEmpty(password))
{
authentication = new Authentication(Util.nonNull(username),
Util.nonNull(password));
}
return new Proxy(Proxy.TYPE_HTTP, configuration.getProxyServer(),
configuration.getProxyPort(), authentication);
}
/**
* Method description
*