Java Code Examples for org.apache.maven.settings.Settings#getActiveProxy()
The following examples show how to use
org.apache.maven.settings.Settings#getActiveProxy() .
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: MavenMvnSettings.java From galleon with Apache License 2.0 | 5 votes |
MavenMvnSettings(MavenConfig config, RepositorySystem repoSystem, RepositoryListener listener) throws ArtifactException { this.config = config; Settings settings = buildMavenSettings(config.getSettings()); Proxy proxy = settings.getActiveProxy(); if (proxy != null) { MavenProxySelector.Builder builder = new MavenProxySelector.Builder(proxy.getHost(), proxy.getPort(), proxy.getProtocol()); builder.setPassword(proxy.getPassword()); builder.setUserName(proxy.getUsername()); if (proxy.getNonProxyHosts() != null) { String[] hosts = proxy.getNonProxyHosts().split("\\|"); builder.addNonProxyHosts(Arrays.asList(hosts)); } proxySelector = builder.build(); Authentication auth = null; if (proxy.getPassword() != null && proxy.getUsername() != null) { auth = new AuthenticationBuilder().addUsername(proxy.getUsername()).addPassword(proxy.getPassword()).build(); } this.proxy = new org.eclipse.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth); } else { this.proxy = null; proxySelector = null; } try { repositories = Collections.unmodifiableList(buildRemoteRepositories(settings)); } catch (MalformedURLException ex) { throw new ArtifactException(ex.getMessage(), ex); } session = Util.newRepositorySession(repoSystem, settings.getLocalRepository() == null ? config.getLocalRepository() : Paths.get(settings.getLocalRepository()), listener, proxySelector, settings.isOffline()); }
Example 2
Source File: RawXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
protected String getActiveProxyAsHttpproxy() { if (getSettings() == null) { return null; } final Settings settings = getSettings(); final Proxy activeProxy = settings.getActiveProxy(); if (activeProxy == null || activeProxy.getHost() == null) { return null; } return createXJCProxyArgument(activeProxy.getHost(), activeProxy.getPort(), activeProxy.getUsername(), activeProxy.getPassword()); }
Example 3
Source File: MavenContainer.java From furnace with Eclipse Public License 1.0 | 5 votes |
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; }
Example 4
Source File: MavenRepositories.java From furnace with Eclipse Public License 1.0 | 5 votes |
static RemoteRepository convertToMavenRepo(final String id, String url, final Settings settings) { RemoteRepository.Builder remoteRepositoryBuilder = new RemoteRepository.Builder(id, "default", url); Proxy activeProxy = settings.getActiveProxy(); if (activeProxy != null) { Authentication auth = new AuthenticationBuilder().addUsername(activeProxy.getUsername()) .addPassword(activeProxy.getPassword()).build(); remoteRepositoryBuilder.setProxy(new org.eclipse.aether.repository.Proxy(activeProxy.getProtocol(), activeProxy .getHost(), activeProxy.getPort(), auth)); } return remoteRepositoryBuilder.build(); }