org.apache.maven.artifact.manager.WagonManager Java Examples

The following examples show how to use org.apache.maven.artifact.manager.WagonManager. 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: DefaultVersionsHelper.java    From versions-maven-plugin with Apache License 2.0 6 votes vote down vote up
private static RuleSet loadRuleSet( String serverId, Settings settings, WagonManager wagonManager, String rulesUri,
                                    Log logger )
    throws MojoExecutionException {
    RuleSet ruleSet = new RuleSet();
    boolean rulesUriGiven = isRulesUriNotBlank(rulesUri);

    if (rulesUriGiven) {
        RuleSet loadedRules;

        if (isClasspathUri(rulesUri)) {
            loadedRules = getRulesFromClasspath(rulesUri, logger);
        } else {
            loadedRules = getRulesViaWagon(rulesUri, logger, serverId, serverId, wagonManager,
                                                   settings);
        }

        ruleSet.setIgnoreVersions(loadedRules.getIgnoreVersions());
        ruleSet.setRules(loadedRules.getRules());
    }

    return ruleSet;
}
 
Example #2
Source File: WagonUtils.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Convenience method to create a wagon.
 *
 * @param serverId The serverId to use if the wagonManager needs help.
 * @param url The url to create a wagon for.
 * @param wagonManager The wgaon manager to use.
 * @param settings The settings to use.
 * @param logger The logger to use.
 * @return The wagon to connect to the url.
 * @throws org.apache.maven.wagon.UnsupportedProtocolException if the protocol is not supported.
 * @throws org.apache.maven.artifact.manager.WagonConfigurationException if the wagon cannot be configured.
 * @throws org.apache.maven.wagon.ConnectionException If the connection cannot be established.
 * @throws org.apache.maven.wagon.authentication.AuthenticationException If the connection cannot be authenticated.
 */
public static Wagon createWagon( String serverId, String url, WagonManager wagonManager, Settings settings,
                                 Log logger )
                                     throws UnsupportedProtocolException, WagonConfigurationException,
                                     ConnectionException, AuthenticationException
{
    Repository repository = new Repository( serverId, url );
    Wagon wagon = wagonManager.getWagon( repository );

    if ( logger.isDebugEnabled() )
    {
        Debug debug = new Debug();
        wagon.addSessionListener( debug );
        wagon.addTransferListener( debug );
    }

    ProxyInfo proxyInfo = getProxyInfo( settings );
    if ( proxyInfo != null )
    {
        wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ), proxyInfo );
    }
    else
    {
        wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ) );
    }
    return wagon;
}
 
Example #3
Source File: AbstractDeployMojo.java    From opoopress with Apache License 2.0 5 votes vote down vote up
public static ProxyInfo getProxyInfo(Repository repository, WagonManager wagonManager) {
    ProxyInfo proxyInfo = wagonManager.getProxy(repository.getProtocol());

    if (proxyInfo == null) {
        return null;
    }

    String host = repository.getHost();
    String nonProxyHostsAsString = proxyInfo.getNonProxyHosts();
    for (String nonProxyHost : StringUtils.split(nonProxyHostsAsString, ",;|")) {
        if (org.apache.commons.lang.StringUtils.contains(nonProxyHost, "*")) {
            // Handle wildcard at the end, beginning or middle of the nonProxyHost
            final int pos = nonProxyHost.indexOf('*');
            String nonProxyHostPrefix = nonProxyHost.substring(0, pos);
            String nonProxyHostSuffix = nonProxyHost.substring(pos + 1);
            // prefix*
            if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix)
                    && StringUtils.isEmpty(nonProxyHostSuffix)) {
                return null;
            }
            // *suffix
            if (StringUtils.isEmpty(nonProxyHostPrefix)
                    && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) {
                return null;
            }
            // prefix*suffix
            if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix)
                    && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) {
                return null;
            }
        } else if (host.equals(nonProxyHost)) {
            return null;
        }
    }
    return proxyInfo;
}
 
Example #4
Source File: DefaultVersionsHelper.java    From versions-maven-plugin with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new {@link DefaultVersionsHelper}.
 *
 * @param artifactFactory The artifact factory.
 * @param artifactResolver Artifact resolver
 * @param artifactMetadataSource The artifact metadata source to use.
 * @param remoteArtifactRepositories The remote artifact repositories to consult.
 * @param remotePluginRepositories The remote plugin repositories to consult.
 * @param localRepository The local repository to consult.
 * @param wagonManager The wagon manager (used if rules need to be retrieved).
 * @param settings The settings (used to provide proxy information to the wagon manager).
 * @param serverId The serverId hint for the wagon manager.
 * @param rulesUri The URL to retrieve the versioning rules from.
 * @param log The {@link org.apache.maven.plugin.logging.Log} to send log messages to.
 * @param mavenSession The maven session information.
 * @param pathTranslator The path translator component. @throws org.apache.maven.plugin.MojoExecutionException If
 *            things go wrong.
 * @throws MojoExecutionException if something goes wrong.
 * @since 1.0-alpha-3
 */
public DefaultVersionsHelper( ArtifactFactory artifactFactory, ArtifactResolver artifactResolver,
                              ArtifactMetadataSource artifactMetadataSource, List remoteArtifactRepositories,
                              List remotePluginRepositories, ArtifactRepository localRepository,
                              WagonManager wagonManager, Settings settings, String serverId, String rulesUri,
                              Log log, MavenSession mavenSession, PathTranslator pathTranslator )
    throws MojoExecutionException
{
    this.artifactFactory = artifactFactory;
    this.artifactResolver = artifactResolver;
    this.mavenSession = mavenSession;
    this.pathTranslator = pathTranslator;
    this.ruleSet = loadRuleSet( serverId, settings, wagonManager, rulesUri, log );
    this.artifactMetadataSource = artifactMetadataSource;
    this.localRepository = localRepository;
    this.remoteArtifactRepositories = remoteArtifactRepositories;
    this.remotePluginRepositories = remotePluginRepositories;
    this.log = log;
}