Java Code Examples for org.eclipse.aether.repository.ProxySelector#getProxy()

The following examples show how to use org.eclipse.aether.repository.ProxySelector#getProxy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MvnSettingsTestCase.java    From galleon with Apache License 2.0 5 votes vote down vote up
@Test
public void testProxy() throws Exception {
    RepositorySystem system = Util.newRepositorySystem();
    MavenConfig config = new MavenConfig();
    InputStream stream = MvnSettingsTestCase.class.getClassLoader().
            getResourceAsStream("settings_cli_test_proxy.xml");
    File tmp = File.createTempFile("cli_mvn_test", null);
    tmp.deleteOnExit();
    Files.copy(stream, tmp.toPath(), StandardCopyOption.REPLACE_EXISTING);
    config.setSettings(tmp.toPath());
    MavenMvnSettings settings = new MavenMvnSettings(config, system, null);
    ProxySelector proxy = settings.getSession().getProxySelector();
    assertEquals(6, settings.getRepositories().size());
    for (RemoteRepository remote : settings.getRepositories()) {
        if (remote.getId().equals("repo1")) {
            assertNull(proxy.getProxy(remote));
            assertNull(remote.getProxy());
        }
        if (remote.getId().equals("repo2")) {
            assertNull(proxy.getProxy(remote));
            assertNull(remote.getProxy());
        }
        if (remote.getId().equals("repo3")) {
            Proxy p = proxy.getProxy(remote);
            assertEquals("proxy1", p.getHost());
            assertNotNull(remote.getProxy());
        }
    }
}
 
Example 2
Source File: CompositeProxySelector.java    From spring-init with Apache License 2.0 5 votes vote down vote up
@Override
public Proxy getProxy(RemoteRepository repository) {
	for (ProxySelector selector : this.selectors) {
		Proxy proxy = selector.getProxy(repository);
		if (proxy != null) {
			return proxy;
		}
	}
	return null;
}
 
Example 3
Source File: ChainedProxySelector.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Proxy getProxy(RemoteRepository repo) {
  Proxy proxy = null;
  
  for (ProxySelector selector : selectors) {
    if (selector != null) {
      proxy = selector.getProxy(repo);
    }
    
    if (proxy != null) return proxy;
  }
  
  return proxy;
}
 
Example 4
Source File: Utils.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Proxy getProxy(RemoteRepository repo, ProxySelector ... selectors) {
  Proxy proxy = null;
  
  for (ProxySelector selector : selectors) {
    if (selector != null) {
      proxy = selector.getProxy(repo);
    }
    
    if (proxy != null) return proxy;
  }
  
  return proxy;
}
 
Example 5
Source File: CompositeProxySelector.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
@Override
public Proxy getProxy(RemoteRepository repository) {
	for (ProxySelector selector : this.selectors) {
		Proxy proxy = selector.getProxy(repository);
		if (proxy != null) {
			return proxy;
		}
	}
	return null;
}