org.eclipse.aether.util.repository.DefaultProxySelector Java Examples

The following examples show how to use org.eclipse.aether.util.repository.DefaultProxySelector. 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: MavenSettings.java    From spring-init with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #2
Source File: GithubImporter.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private static RepositorySystemSession newSession(RepositorySystem system) {
	DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
	LocalRepository localRepo = new LocalRepository("target/local-repo");
	session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
	// set possible proxies and mirrors
	session.setProxySelector(new DefaultProxySelector().add(new Proxy(Proxy.TYPE_HTTP, "host", 3625),
			Arrays.asList("localhost", "127.0.0.1")));
	session.setMirrorSelector(
			new DefaultMirrorSelector().add("my-mirror", "http://mirror", "default", false, "external:*", null));
	return session;
}
 
Example #3
Source File: MavenArtifactResolver.java    From spring-cloud-deployer with Apache License 2.0 5 votes vote down vote up
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());
	session.setUpdatePolicy(this.properties.getUpdatePolicy());
	session.setChecksumPolicy(this.properties.getChecksumPolicy());
	if (this.properties.isEnableRepositoryListener()) {
		session.setRepositoryListener(new LoggingRepositoryListener());
	}
	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.proxyAuthentication);
		proxySelector.add(proxy, this.properties.getProxy().getNonProxyHosts());
		session.setProxySelector(proxySelector);
	}
	// wagon configs
	for (Entry<String, MavenProperties.RemoteRepository> entry : this.properties.getRemoteRepositories().entrySet()) {
		session.setConfigProperty("aether.connector.wagon.config." + entry.getKey(), entry.getValue().getWagon());
	}
	return session;
}
 
Example #4
Source File: MavenSettings.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: MavenContainer.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
public DefaultRepositorySystemSession setupRepoSession(final RepositorySystem repoSystem, final Settings settings)
{
   DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
   session.setOffline(false);

   Proxy activeProxy = settings.getActiveProxy();
   if (activeProxy != null)
   {
      DefaultProxySelector dps = new DefaultProxySelector();
      dps.add(convertFromMavenProxy(activeProxy), activeProxy.getNonProxyHosts());
      session.setProxySelector(dps);
   }

   final DefaultMirrorSelector mirrorSelector = createMirrorSelector(settings);
   final LazyAuthenticationSelector authSelector = createAuthSelector(settings, mirrorSelector);

   session.setMirrorSelector(mirrorSelector);
   session.setAuthenticationSelector(authSelector);

   LocalRepository localRepo = new LocalRepository(new File(settings.getLocalRepository()));
   session.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(session, localRepo));
   session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_IGNORE);
   session.setCache(new DefaultRepositoryCache());
   boolean cacheNotFoundArtifacts = true;
   boolean cacheTransferErrors = true;
   session.setResolutionErrorPolicy(new SimpleResolutionErrorPolicy(cacheNotFoundArtifacts, cacheTransferErrors));
   session.setWorkspaceReader(new ClasspathWorkspaceReader());
   if (Boolean.getBoolean("org.apache.maven.log_transfer"))
   {
      session.setTransferListener(new JULMavenTransferListener());
   }
   return session;
}