org.apache.maven.settings.Settings.getActiveProxy()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.apache.maven.settings.Settings.getActiveProxy()方法的一些代码示例,展示了Settings.getActiveProxy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getActiveProxy()方法的具体详情如下:
包路径:org.apache.maven.settings.Settings
类名称:Settings
方法名:getActiveProxy

Settings.getActiveProxy介绍

暂无

代码示例

代码示例来源:origin: trautonen/coveralls-maven-plugin

/**
 * @return http client that submits the coveralls data
 */
protected CoverallsClient createCoverallsClient() {
  return new CoverallsProxyClient(coverallsUrl, settings.getActiveProxy());
}

代码示例来源:origin: org.eluder.coveralls/coveralls-maven-plugin

/**
 * @return http client that submits the coveralls data
 */
protected CoverallsClient createCoverallsClient() {
  return new CoverallsProxyClient(coverallsUrl, settings.getActiveProxy());
}

代码示例来源:origin: SonarSource/sonar-scanner-maven

public void setProxySystemProperties() {
  Proxy activeProxy = session.getSettings().getActiveProxy();

  if (activeProxy != null && activeProxy.getProtocol() != null && activeProxy.getProtocol().contains("http")) {
   log.debug("Setting proxy properties");
   System.setProperty("http.proxyHost", activeProxy.getHost());
   System.setProperty("http.proxyPort", String.valueOf(activeProxy.getPort()));
   System.setProperty("http.proxyUser", StringUtils.defaultString(activeProxy.getUsername(), ""));
   System.setProperty("http.proxyPassword", StringUtils.defaultString(activeProxy.getPassword(), ""));
   System.setProperty("http.nonProxyHosts", StringUtils.defaultString(activeProxy.getNonProxyHosts(), ""));
  }
 }
}

代码示例来源:origin: raydac/mvn-golang

@Nullable
private ProxySettings extractProxySettings() {
 final ProxySettings result;
 if (this.isUseMavenProxy()) {
  final Proxy activeMavenProxy = this.settings == null ? null : this.settings.getActiveProxy();
  result = activeMavenProxy == null ? null : new ProxySettings(activeMavenProxy);
  getLog().debug("Detected maven proxy : " + result);
 } else {
  result = this.proxy;
  if (result != null) {
   getLog().debug("Defined proxy : " + result);
  }
 }
 return result;
}

代码示例来源:origin: mulesoft-attic/npm-maven-plugin

public void execute() throws MojoExecutionException {
    Log log = getLog();

    NPMModule.proxy = settings.getActiveProxy();
    for (String aPackage : packages) {
      NPMModule.fromQueryString(log,aPackage).saveToFileWithDependencies(outputDirectory);
    }
  }
}

代码示例来源:origin: maven-gae-plugin/maven-gae-plugin

private void addProxyOption(final List<String> args) {
 if (isNotEmpty(proxy)) {
  addStringOption(args, "--proxy=", proxy);
 } else if (hasServerSettings()) {
  final Proxy activCfgProxy = settings.getActiveProxy();
  if (activCfgProxy != null) {
   addStringOption(args, "--proxy=", activCfgProxy.getHost() + ":" + activCfgProxy.getPort());
  }
 }
}

代码示例来源:origin: ingenieux/beanstalker

protected ClientConfiguration getClientConfiguration() {
 ClientConfiguration clientConfiguration = new ClientConfiguration().withUserAgent(getUserAgent());
 if (null != this.settings && null != settings.getActiveProxy()) {
  Proxy proxy = settings.getActiveProxy();
  clientConfiguration.setProxyHost(proxy.getHost());
  clientConfiguration.setProxyUsername(proxy.getUsername());
  clientConfiguration.setProxyPassword(proxy.getPassword());
  clientConfiguration.setProxyPort(proxy.getPort());
 }
 return clientConfiguration;
}

代码示例来源:origin: highsource/maven-jaxb2-plugin

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());
}

代码示例来源:origin: org.jvnet.jaxb2.maven2/maven-jaxb2-plugin-core

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());
}

代码示例来源:origin: org.apache.felix/maven-bundle-plugin

/**
 * Convenience method to map a Proxy object from the user system settings to a ProxyInfo object.
 * @param settings project settings given by maven
 * @return a proxyInfo object instancied or null if no active proxy is define in the settings.xml
 */
public static ProxyInfo getProxyInfo( Settings settings )
{
  ProxyInfo proxyInfo = null;
  if ( settings != null && settings.getActiveProxy() != null )
  {
    Proxy settingsProxy = settings.getActiveProxy();
    proxyInfo = new ProxyInfo();
    proxyInfo.setHost( settingsProxy.getHost() );
    proxyInfo.setType( settingsProxy.getProtocol() );
    proxyInfo.setPort( settingsProxy.getPort() );
    proxyInfo.setNonProxyHosts( settingsProxy.getNonProxyHosts() );
    proxyInfo.setUserName( settingsProxy.getUsername() );
    proxyInfo.setPassword( settingsProxy.getPassword() );
  }
  return proxyInfo;
}

代码示例来源:origin: jmeter-maven-plugin/jmeter-maven-plugin

/**
 * Try to load the active maven proxy.
 */
protected void loadMavenProxy() {
  if (settings == null)
    return;
  try {
    Proxy mvnProxy = settings.getActiveProxy();
    if (mvnProxy != null) {
      ProxyConfiguration newProxyConf = new ProxyConfiguration();
      newProxyConf.setHost(mvnProxy.getHost());
      newProxyConf.setPort(mvnProxy.getPort());
      newProxyConf.setUsername(mvnProxy.getUsername());
      newProxyConf.setPassword(mvnProxy.getPassword());
      newProxyConf.setHostExclusions(mvnProxy.getNonProxyHosts());
      proxyConfig = newProxyConf;
      getLog().info("Maven proxy loaded successfully");
    } else {
      getLog().warn("No maven proxy found, but useMavenProxy set to true.");
    }
  } catch (Exception e) {
    getLog().error("Error while loading maven proxy", e);
  }
}

代码示例来源:origin: org.codehaus.mojo/wagon-maven-plugin

/**
 * Convenience method to map a <code>Proxy</code> object from the user system settings to a <code>ProxyInfo</code>
 * object.
 *
 * @return a proxyInfo object or null if no active proxy is define in the settings.xml
 */
private static ProxyInfo getProxyInfo( Settings settings )
{
  ProxyInfo proxyInfo = null;
  if ( settings != null && settings.getActiveProxy() != null )
  {
    Proxy settingsProxy = settings.getActiveProxy();
    proxyInfo = new ProxyInfo();
    proxyInfo.setHost( settingsProxy.getHost() );
    proxyInfo.setType( settingsProxy.getProtocol() );
    proxyInfo.setPort( settingsProxy.getPort() );
    proxyInfo.setNonProxyHosts( settingsProxy.getNonProxyHosts() );
    proxyInfo.setUserName( settingsProxy.getUsername() );
    proxyInfo.setPassword( settingsProxy.getPassword() );
  }
  return proxyInfo;
}

代码示例来源:origin: mojohaus/versions-maven-plugin

/**
 * Convenience method to convert the {@link org.apache.maven.settings.Proxy} object from a
 * {@link org.apache.maven.settings.Settings} into a {@link org.apache.maven.wagon.proxy.ProxyInfo}.
 *
 * @param settings The settings to use.
 * @return The proxy details from the settings or <code>null</code> if the settings do not define a proxy.
 */
public static ProxyInfo getProxyInfo( Settings settings )
{
  ProxyInfo proxyInfo = null;
  if ( settings != null && settings.getActiveProxy() != null )
  {
    proxyInfo = new ProxyInfo();
    final Proxy proxy = settings.getActiveProxy();
    proxyInfo.setHost( proxy.getHost() );
    proxyInfo.setType( proxy.getProtocol() );
    proxyInfo.setPort( proxy.getPort() );
    proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() );
    proxyInfo.setUserName( proxy.getUsername() );
    proxyInfo.setPassword( proxy.getPassword() );
  }
  return proxyInfo;
}

代码示例来源:origin: org.jboss.galleon/galleon-cli

MavenMvnSettings(MavenConfig config, RepositorySystem repoSystem, RepositoryListener listener) throws ArtifactException {
  Settings settings = buildMavenSettings(config.getSettings());
  repositories = Collections.unmodifiableList(buildRemoteRepositories(settings));
  Proxy proxy = settings.getActiveProxy();
  MavenProxySelector proxySelector = null;
  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();
  }
  session = Util.newRepositorySession(repoSystem,
      settings.getLocalRepository() == null ? config.getLocalRepository() : Paths.get(settings.getLocalRepository()),
      listener, proxySelector, settings.isOffline());
}

代码示例来源:origin: org.codehaus.mojo/versions-maven-plugin

/**
 * Convenience method to convert the {@link org.apache.maven.settings.Proxy} object from a
 * {@link org.apache.maven.settings.Settings} into a {@link org.apache.maven.wagon.proxy.ProxyInfo}.
 *
 * @param settings The settings to use.
 * @return The proxy details from the settings or <code>null</code> if the settings do not define a proxy.
 */
public static ProxyInfo getProxyInfo( Settings settings )
{
  ProxyInfo proxyInfo = null;
  if ( settings != null && settings.getActiveProxy() != null )
  {
    proxyInfo = new ProxyInfo();
    final Proxy proxy = settings.getActiveProxy();
    proxyInfo.setHost( proxy.getHost() );
    proxyInfo.setType( proxy.getProtocol() );
    proxyInfo.setPort( proxy.getPort() );
    proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() );
    proxyInfo.setUserName( proxy.getUsername() );
    proxyInfo.setPassword( proxy.getPassword() );
  }
  return proxyInfo;
}

代码示例来源:origin: org.jboss.forge/maven-impl

static RemoteRepository convertToMavenRepo(final DependencyRepository repo, final Settings settings)
{
 RemoteRepository remoteRepository = new RemoteRepository(repo.getId(), "default", repo.getUrl());
 Proxy activeProxy = settings.getActiveProxy();
 if (activeProxy != null)
 {
   Authentication auth = new Authentication(activeProxy.getUsername(), activeProxy.getPassword());
   remoteRepository.setProxy(new org.sonatype.aether.repository.Proxy(activeProxy.getProtocol(), activeProxy
       .getHost(), activeProxy.getPort(), auth));
 }
 return remoteRepository;
}

代码示例来源:origin: org.jboss.forge.furnace/furnace-manager-resolver-maven

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();
}

代码示例来源:origin: org.jboss.forge.addon/maven-impl

public static RemoteRepository convertToMavenRepo(final DependencyRepository repo, final Settings settings)
{
 RemoteRepository.Builder remoteRepositoryBuilder = new RemoteRepository.Builder(repo.getId(), "default",
      repo.getUrl());
 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();
}

代码示例来源:origin: apache/karaf

private org.apache.maven.repository.Proxy configureProxyToInlineRepo() {
  if (mavenSession != null && mavenSession.getSettings() != null) {
    Proxy proxy = mavenSession.getSettings().getActiveProxy();
    org.apache.maven.repository.Proxy mavenProxy = new org.apache.maven.repository.Proxy();
    if (proxy != null) {
      mavenProxy.setProtocol(proxy.getProtocol());
      mavenProxy.setHost(proxy.getHost());
      mavenProxy.setPort(proxy.getPort());
      mavenProxy.setNonProxyHosts(proxy.getNonProxyHosts());
      mavenProxy.setUserName(proxy.getUsername());
      mavenProxy.setPassword(proxy.getPassword());
      return mavenProxy;
    } else {
      return null;
    }
    
  } else {
    return null;
  }
}

代码示例来源:origin: org.apache.karaf.tooling/karaf-maven-plugin

private org.apache.maven.repository.Proxy configureProxyToInlineRepo() {
  if (mavenSession != null && mavenSession.getSettings() != null) {
    Proxy proxy = mavenSession.getSettings().getActiveProxy();
    org.apache.maven.repository.Proxy mavenProxy = new org.apache.maven.repository.Proxy();
    if (proxy != null) {
      mavenProxy.setProtocol(proxy.getProtocol());
      mavenProxy.setHost(proxy.getHost());
      mavenProxy.setPort(proxy.getPort());
      mavenProxy.setNonProxyHosts(proxy.getNonProxyHosts());
      mavenProxy.setUserName(proxy.getUsername());
      mavenProxy.setPassword(proxy.getPassword());
      return mavenProxy;
    } else {
      return null;
    }
    
  } else {
    return null;
  }
}

相关文章