Java Code Examples for org.apache.maven.execution.MavenSession#getSettings()

The following examples show how to use org.apache.maven.execution.MavenSession#getSettings() . 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: MojoUtils.java    From frontend-maven-plugin with Apache License 2.0 6 votes vote down vote up
static ProxyConfig getProxyConfig(MavenSession mavenSession, SettingsDecrypter decrypter) {
    if (mavenSession == null ||
            mavenSession.getSettings() == null ||
            mavenSession.getSettings().getProxies() == null ||
            mavenSession.getSettings().getProxies().isEmpty()) {
        return new ProxyConfig(Collections.<ProxyConfig.Proxy>emptyList());
    } else {
        final List<Proxy> mavenProxies = mavenSession.getSettings().getProxies();

        final List<ProxyConfig.Proxy> proxies = new ArrayList<ProxyConfig.Proxy>(mavenProxies.size());

        for (Proxy mavenProxy : mavenProxies) {
            if (mavenProxy.isActive()) {
                mavenProxy = decryptProxy(mavenProxy, decrypter);
                proxies.add(new ProxyConfig.Proxy(mavenProxy.getId(), mavenProxy.getProtocol(), mavenProxy.getHost(),
                        mavenProxy.getPort(), mavenProxy.getUsername(), mavenProxy.getPassword(), mavenProxy.getNonProxyHosts()));
            }
        }

        LOGGER.info("Found proxies: {}", proxies);
        return new ProxyConfig(proxies);
    }
}
 
Example 2
Source File: MojoUtils.java    From wisdom with Apache License 2.0 6 votes vote down vote up
public static ProxyConfig getProxyConfig(MavenSession mavenSession, SettingsDecrypter decrypter) {
    if (mavenSession == null ||
            mavenSession.getSettings() == null ||
            mavenSession.getSettings().getProxies() == null ||
            mavenSession.getSettings().getProxies().isEmpty()) {
        return new ProxyConfig(Collections.<ProxyConfig.Proxy>emptyList());
    } else {
        final List<Proxy> mavenProxies = mavenSession.getSettings().getProxies();

        final List<ProxyConfig.Proxy> proxies = new ArrayList<>(mavenProxies.size());

        for (Proxy mavenProxy : mavenProxies) {
            if (mavenProxy.isActive()) {
                mavenProxy = decryptProxy(mavenProxy, decrypter);
                proxies.add(new ProxyConfig.Proxy(mavenProxy.getId(), mavenProxy.getProtocol(), mavenProxy.getHost(),
                        mavenProxy.getPort(), mavenProxy.getUsername(), mavenProxy.getPassword(), mavenProxy.getNonProxyHosts()));
            }
        }

        return new ProxyConfig(proxies);
    }
}
 
Example 3
Source File: DockerAssemblyConfigurationSource.java    From docker-maven-plugin with Apache License 2.0 5 votes vote down vote up
private FixedStringSearchInterpolator createRepositoryInterpolator()
{
    final Properties settingsProperties = new Properties();
    final MavenSession session = getMavenSession();

    if (getLocalRepository() != null) {
        settingsProperties.setProperty("localRepository", getLocalRepository().getBasedir());
        settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir());
    }
    else if (session != null && session.getSettings() != null) {
        settingsProperties.setProperty("localRepository", session.getSettings().getLocalRepository() );
        settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir() );
    }
    return FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(settingsProperties));
}