All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.whitesource.maven.utils.proxy.ProxySettingsProviderFactory Maven / Gradle / Ivy

There is a newer version: 20.7.1
Show newest version
package org.whitesource.maven.utils.proxy;

import org.apache.maven.execution.MavenSession;
import org.whitesource.maven.utils.proxy.impl.EclipseAetherProxySettingsProvider;
import org.whitesource.maven.utils.proxy.impl.SonatypeAetherProxySettingsProvider;

/**
 * Author: Itai Marko
 */
public class ProxySettingsProviderFactory {

    private final static boolean isEclipseAetherLoaded;

    static {
        isEclipseAetherLoaded = isExistsInClasspath("org.eclipse.aether.repository.Proxy");
    }

    private static boolean isExistsInClasspath(String className) {
        try {
            Thread.currentThread().getContextClassLoader().loadClass(className);
            return true;
        } catch (ClassNotFoundException e) {
            return false;
        }
    }

    public static ProxySettingsProvider getProxySettingsProviderForUrl(String url, MavenSession session) {
        if (isEclipseAetherLoaded) {
            return new EclipseAetherProxySettingsProvider(url, session);
        } else {
            return new SonatypeAetherProxySettingsProvider(url, session);
        }
    }

    // prevent instantiation
    private ProxySettingsProviderFactory() {}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy