use of org.eclipse.aether.util.repository.DefaultProxySelector in project gate-core by GateNLP.
the class Utils method getRepositoryList.
public static List<RemoteRepository> getRepositoryList() throws SettingsBuildingException {
List<RemoteRepository> repos = new ArrayList<RemoteRepository>();
RemoteRepository central = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
// Without this we wouldn't be able to find SNAPSHOT builds of plugins we
// haven't built and installed locally ourselves
RemoteRepository gateRepo = new RemoteRepository.Builder("gate", "default", "http://repo.gate.ac.uk/content/groups/public/").build();
// Add all repos from settings.xml
// http://stackoverflow.com/questions/27818659/loading-mavens-settings-xml-for-jcabi-aether-to-use
Settings effectiveSettings = loadMavenSettings();
org.apache.maven.settings.Proxy proxy = effectiveSettings.getActiveProxy();
DefaultProxySelector selector = null;
if (proxy != null) {
selector = new DefaultProxySelector();
selector.add(new Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), new AuthenticationBuilder().addUsername(proxy.getUsername()).addPassword(proxy.getPassword()).build()), proxy.getNonProxyHosts());
}
Map<String, Profile> profilesMap = effectiveSettings.getProfilesAsMap();
for (String profileName : effectiveSettings.getActiveProfiles()) {
Profile profile = profilesMap.get(profileName);
List<Repository> repositories = profile.getRepositories();
for (Repository repo : repositories) {
RemoteRepository remoteRepo = new RemoteRepository.Builder(repo.getId(), "default", repo.getUrl()).build();
if (selector != null) {
remoteRepo = new RemoteRepository.Builder(remoteRepo).setProxy(selector.getProxy(remoteRepo)).build();
}
repos.add(remoteRepo);
}
}
repos.add(central);
repos.add(gateRepo);
return repos;
}
use of org.eclipse.aether.util.repository.DefaultProxySelector in project spring-cloud-function by spring-cloud.
the class MavenSettings method createProxySelector.
private ProxySelector createProxySelector(SettingsDecryptionResult decryptedSettings) {
DefaultProxySelector selector = new DefaultProxySelector();
for (Proxy proxy : decryptedSettings.getProxies()) {
Authentication authentication = new AuthenticationBuilder().addUsername(proxy.getUsername()).addPassword(proxy.getPassword()).build();
selector.add(new org.eclipse.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authentication), proxy.getNonProxyHosts());
}
return selector;
}
use of org.eclipse.aether.util.repository.DefaultProxySelector in project fabric8 by jboss-fuse.
the class AetherBasedResolver method selectProxies.
private ProxySelector selectProxies() {
DefaultProxySelector proxySelector = new DefaultProxySelector();
for (org.apache.maven.settings.Proxy proxy : m_settings.getProxies()) {
if (!proxy.isActive()) {
continue;
}
String nonProxyHosts = proxy.getNonProxyHosts();
Proxy proxyObj = new Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), getAuthentication(proxy));
proxySelector.add(proxyObj, nonProxyHosts);
}
return proxySelector;
}
use of org.eclipse.aether.util.repository.DefaultProxySelector in project spring-cloud-deployer by spring-cloud.
the class MavenArtifactResolver method newRepositorySystemSession.
/*
* Create a session to manage remote and local synchronization.
*/
private DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system, String localRepoPath) {
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepo = new LocalRepository(localRepoPath);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
session.setOffline(this.properties.isOffline());
if (this.properties.getConnectTimeout() != null) {
session.setConfigProperty(ConfigurationProperties.CONNECT_TIMEOUT, this.properties.getConnectTimeout());
}
if (this.properties.getRequestTimeout() != null) {
session.setConfigProperty(ConfigurationProperties.REQUEST_TIMEOUT, this.properties.getRequestTimeout());
}
if (isProxyEnabled()) {
DefaultProxySelector proxySelector = new DefaultProxySelector();
Proxy proxy = new Proxy(this.properties.getProxy().getProtocol(), this.properties.getProxy().getHost(), this.properties.getProxy().getPort(), this.authentication);
proxySelector.add(proxy, this.properties.getProxy().getNonProxyHosts());
session.setProxySelector(proxySelector);
}
return session;
}
use of org.eclipse.aether.util.repository.DefaultProxySelector in project spring-boot by spring-projects.
the class MavenSettings method createProxySelector.
private ProxySelector createProxySelector(SettingsDecryptionResult decryptedSettings) {
DefaultProxySelector selector = new DefaultProxySelector();
for (Proxy proxy : decryptedSettings.getProxies()) {
Authentication authentication = new AuthenticationBuilder().addUsername(proxy.getUsername()).addPassword(proxy.getPassword()).build();
selector.add(new org.eclipse.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authentication), proxy.getNonProxyHosts());
}
return selector;
}
Aggregations