Search in sources :

Example 1 with DefaultProxySelector

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;
}
Also used : AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) DefaultProxySelector(org.eclipse.aether.util.repository.DefaultProxySelector) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Profile(org.apache.maven.settings.Profile) Proxy(org.eclipse.aether.repository.Proxy) Repository(org.apache.maven.settings.Repository) LocalRepository(org.eclipse.aether.repository.LocalRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Settings(org.apache.maven.settings.Settings)

Example 2 with DefaultProxySelector

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;
}
Also used : Proxy(org.apache.maven.settings.Proxy) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) DefaultProxySelector(org.eclipse.aether.util.repository.DefaultProxySelector) Authentication(org.eclipse.aether.repository.Authentication)

Example 3 with DefaultProxySelector

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;
}
Also used : Proxy(org.eclipse.aether.repository.Proxy) DefaultProxySelector(org.eclipse.aether.util.repository.DefaultProxySelector)

Example 4 with DefaultProxySelector

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;
}
Also used : Proxy(org.eclipse.aether.repository.Proxy) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) DefaultProxySelector(org.eclipse.aether.util.repository.DefaultProxySelector) LocalRepository(org.eclipse.aether.repository.LocalRepository)

Example 5 with DefaultProxySelector

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;
}
Also used : Proxy(org.apache.maven.settings.Proxy) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) DefaultProxySelector(org.eclipse.aether.util.repository.DefaultProxySelector) Authentication(org.eclipse.aether.repository.Authentication)

Aggregations

DefaultProxySelector (org.eclipse.aether.util.repository.DefaultProxySelector)5 Proxy (org.eclipse.aether.repository.Proxy)3 AuthenticationBuilder (org.eclipse.aether.util.repository.AuthenticationBuilder)3 Proxy (org.apache.maven.settings.Proxy)2 Authentication (org.eclipse.aether.repository.Authentication)2 LocalRepository (org.eclipse.aether.repository.LocalRepository)2 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Profile (org.apache.maven.settings.Profile)1 Repository (org.apache.maven.settings.Repository)1 Settings (org.apache.maven.settings.Settings)1 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1