Package org.apache.maven.artifact.manager

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


     * the wagons, shouldn't we?
     */
    private void resolveParameters( Settings settings, Properties executionProperties )
        throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException
    {
        WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );

        try
        {
            if ( settings.isOffline() )
            {
                getLogger().info( SystemWarnings.getOfflineWarning() );
   
                wagonManager.setOnline( false );
            }

            try
            {
                DefaultWagonManager wm = (DefaultWagonManager) wagonManager;
           
                String oldUserAgent = wm.getHttpUserAgent();
                int firstSpace = oldUserAgent == null ? -1 : oldUserAgent.indexOf( " " );
           
                StringBuffer buffer = new StringBuffer();
           
                buffer.append( "Apache-Maven/" );
           
                ArtifactVersion version = runtimeInformation.getApplicationVersion();
                if ( version != null )
                {
                    buffer.append( version.getMajorVersion() );
                    buffer.append( '.' );
                    buffer.append( version.getMinorVersion() );
                }
                else
                {
                    buffer.append( "unknown" );
                }
               
                buffer.append( ' ' );
                if ( firstSpace > -1 )
                {
                    buffer.append( oldUserAgent.substring( firstSpace + 1 ) );
                    buffer.append( ' ' );
                    buffer.append( oldUserAgent.substring( 0, firstSpace ) );
                }
                else
                {
                    buffer.append( oldUserAgent );
                }
               
                wm.setHttpUserAgent( buffer.toString() );
            }
            catch ( ClassCastException e )
            {
                // ignore
            }

            SecDispatcher sd = null;
       
            try
            {
                Proxy proxy = settings.getActiveProxy();
           
                try
                {
                    sd = (SecDispatcher) container.lookup( SecDispatcher.ROLE, "maven" );
                }
                catch (Exception e)
                {
                    getLogger().warn( "Security features are disabled. Cannot find plexus component "+SecDispatcher.ROLE + ":maven" );
                   
                    line();
                }
   
                if ( proxy != null )
                {
                    if ( proxy.getHost() == null )
                    {
                        throw new SettingsConfigurationException( "Proxy in settings.xml has no host" );
                    }
                   
                    String pass = proxy.getPassword();
                   
                    if ( sd != null )
                    {
                        try
                        {
                            pass = sd.decrypt( pass );
                        }
                        catch ( SecDispatcherException e )
                        {
                            reportSecurityConfigurationError( "password for proxy '" + proxy.getId() + "'", e );
                        }
                    }
   
                    wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(),
                                           pass, proxy.getNonProxyHosts() );
                }
               
                for ( Iterator i = settings.getServers().iterator(); i.hasNext(); )
                {
                    Server server = (Server) i.next();
                   
                    String passWord = server.getPassword();
   
                    if ( sd != null )
                    {
                        try
                        {
                            passWord = sd.decrypt( passWord );
                        }
                        catch ( SecDispatcherException e )
                        {
                            reportSecurityConfigurationError( "password for server '" + server.getId() + "'", e );
                        }
                    }
                   
                    String passPhrase = server.getPassphrase();
   
                    if ( sd != null )
                    {
                        try
                        {
                            passPhrase = sd.decrypt( passPhrase );
                        }
                        catch ( SecDispatcherException e )
                        {
                            reportSecurityConfigurationError( "passphrase for server '" + server.getId() + "'", e );
                        }
                    }
   
                    wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), passWord,
                                                        server.getPrivateKey(), passPhrase );
   
                    wagonManager.addPermissionInfo( server.getId(), server.getFilePermissions(),
                                                    server.getDirectoryPermissions() );
   
                    if ( server.getConfiguration() != null )
                    {
                        wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration() );
                    }
                }
   
                for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); )
                {
                    Mirror mirror = (Mirror) i.next();
   
                    wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
                }
            }
            finally
            {
                if ( sd != null )
View Full Code Here


    private static Maven createMavenInstance( boolean interactive )
        throws ComponentLookupException
    {
        // TODO [BP]: doing this here as it is CLI specific, though it doesn't feel like the right place (likewise logger).
        WagonManager wagonManager = (WagonManager) embedder.lookup( WagonManager.ROLE );
        if ( interactive )
        {
            wagonManager.setDownloadMonitor( new ConsoleDownloadMonitor() );
        }
        else
        {
            wagonManager.setDownloadMonitor( new BatchModeDownloadMonitor() );
        }

        wagonManager.setInteractive( interactive );

        return (Maven) embedder.lookup( Maven.ROLE );
    }
View Full Code Here

    {
        if ( request.getSettings().isOffline() )
        {
            getLogger().info( SystemWarnings.getOfflineWarning() );

            WagonManager wagonManager = null;

            try
            {
                wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );

                wagonManager.setOnline( false );
            }
            catch ( ComponentLookupException e )
            {
                throw new MavenExecutionException( "Cannot retrieve WagonManager in order to set offline mode.", e );
            }
View Full Code Here

        catch ( ClassCastException e )
        {
            // ignore
        }

        WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );

        try
        {
            Proxy proxy = settings.getActiveProxy();

            if ( proxy != null )
            {
                if ( proxy.getHost() == null )
                {
                    throw new SettingsConfigurationException( "Proxy in settings.xml has no host" );
                }

                wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(),
                                       proxy.getPassword(), proxy.getNonProxyHosts() );
            }

            for ( Iterator i = settings.getServers().iterator(); i.hasNext(); )
            {
                Server server = (Server) i.next();

                wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), server.getPassword(),
                                                    server.getPrivateKey(), server.getPassphrase() );

                // Remove once Wagon is upgraded to 1.0-beta-5
                if ( server.getPassword() != null )
                {
                    // setting this globally is not ideal, but not harmful
                    com.jcraft.jsch.JSch.setConfig( "PreferredAuthentications", "gssapi-with-mic,publickey,password,keyboard-interactive" );
                }

                wagonManager.addPermissionInfo( server.getId(), server.getFilePermissions(),
                                                server.getDirectoryPermissions() );

                if ( server.getConfiguration() != null )
                {
                    wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration() );
                }
            }

            RepositoryPermissions defaultPermissions = new RepositoryPermissions();

            defaultPermissions.setDirectoryMode( "775" );

            defaultPermissions.setFileMode( "664" );

            wagonManager.setDefaultRepositoryPermissions( defaultPermissions );

            for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); )
            {
                Mirror mirror = (Mirror) i.next();

                wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
            }
        }
        finally
        {
            container.release( wagonManager );
View Full Code Here

    public void testResolutionFailureWhenArtifactNotPresentInRemoteRepositoryWithMirrors()
        throws Exception
    {
        ArtifactRepository repository = remoteRepository();

        WagonManager wagonManager = (WagonManager) lookup( WagonManager.ROLE );
        wagonManager.addMirror( "mirror", "test", repository.getUrl() );

        Artifact k = createArtifact( "k", "1.0" );

        try
        {
View Full Code Here

    private static Maven createMavenInstance( boolean interactive, Logger logger )
        throws ComponentLookupException
    {
        // TODO [BP]: doing this here as it is CLI specific, though it doesn't feel like the right place (likewise logger).
        WagonManager wagonManager = (WagonManager) embedder.lookup( WagonManager.ROLE );
        if ( interactive )
        {
            wagonManager.setDownloadMonitor( new ConsoleDownloadMonitor( logger ) );
        }
        else
        {
            wagonManager.setDownloadMonitor( new BatchModeDownloadMonitor( logger ) );
        }

        wagonManager.setInteractive( interactive );

        return (Maven) embedder.lookup( Maven.ROLE );
    }
View Full Code Here

        String outputDirectory = new File( getBasedir(),
                                           "target" + File.separator + "test-classes" + File.separator + "projects"
                                               + File.separator + "roundtrip-2-recreatedproject" ).getAbsolutePath();
        FileUtils.forceDelete( outputDirectory );

        WagonManager manager = (WagonManager) lookup( WagonManager.class.getName() );
        manager.addProxy( "http", "localhost", proxyPort, null, null, null );

        ArchetypeGenerationRequest agr =
            new ArchetypeGenerationRequest().setArchetypeGroupId( generatedArchetypeProject.getGroupId() ).
                setArchetypeArtifactId( generatedArchetypeProject.getArtifactId() ).
                setArchetypeVersion( generatedArchetypeProject.getVersion() ).
View Full Code Here

     * the wagons, shouldn't we?
     */
    private void resolveParameters( Settings settings )
        throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException
    {
        WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );

        try
        {
            Proxy proxy = settings.getActiveProxy();

            if ( proxy != null )
            {
                if ( proxy.getHost() == null )
                {
                    throw new SettingsConfigurationException( "Proxy in settings.xml has no host" );
                }

                wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(),
                                       proxy.getPassword(), proxy.getNonProxyHosts() );
            }

            for ( Server server : (List<Server>) settings.getServers() )
            {
                wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), server.getPassword(),
                                                    server.getPrivateKey(), server.getPassphrase() );

                wagonManager.addPermissionInfo( server.getId(), server.getFilePermissions(),
                                                server.getDirectoryPermissions() );

                if ( server.getConfiguration() != null )
                {
                    wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration() );
                }
            }

            for ( Mirror mirror : (List<Mirror>) settings.getMirrors() )
            {
                wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
            }
        }
        finally
        {
            container.release( wagonManager );
View Full Code Here

     * the wagons, shouldn't we?
     */
    private void resolveParameters( Settings settings )
        throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException
    {
        WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );

        try
        {
            Proxy proxy = settings.getActiveProxy();

            if ( proxy != null )
            {
                if ( proxy.getHost() == null )
                {
                    throw new SettingsConfigurationException( "Proxy in settings.xml has no host" );
                }

                wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(),
                                       proxy.getPassword(), proxy.getNonProxyHosts() );
            }

            for ( Server server : (List<Server>) settings.getServers() )
            {
                wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), server.getPassword(),
                                                    server.getPrivateKey(), server.getPassphrase() );

                wagonManager.addPermissionInfo( server.getId(), server.getFilePermissions(),
                                                server.getDirectoryPermissions() );

                if ( server.getConfiguration() != null )
                {
                    wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration() );
                }
            }

            for ( Mirror mirror : (List<Mirror>) settings.getMirrors() )
            {
                wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
            }
        }
        finally
        {
            container.release( wagonManager );
View Full Code Here

    }

    private static void initializeWagon( DefaultPlexusContainer container )
        throws ComponentLookupException, ComponentLifecycleException, IOException
    {
        WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );

        Settings settings = getSettings( container );

        try
        {
            Proxy proxy = settings.getActiveProxy();

            if ( proxy != null )
            {
                if ( proxy.getHost() == null )
                {
                    throw new IOException( "Proxy in settings.xml has no host" );
                }

                wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(),
                                       proxy.getPassword(), proxy.getNonProxyHosts() );
            }

            for ( Iterator i = settings.getServers().iterator(); i.hasNext(); )
            {
                Server server = (Server) i.next();

                wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), server.getPassword(),
                                                    server.getPrivateKey(), server.getPassphrase() );

                wagonManager.addPermissionInfo( server.getId(), server.getFilePermissions(),
                                                server.getDirectoryPermissions() );

                if ( server.getConfiguration() != null )
                {
                    wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration() );
                }
            }

            RepositoryPermissions defaultPermissions = new RepositoryPermissions();

            defaultPermissions.setDirectoryMode( "775" );

            defaultPermissions.setFileMode( "664" );

            wagonManager.setDefaultRepositoryPermissions( defaultPermissions );

            for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); )
            {
                Mirror mirror = (Mirror) i.next();

                wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
            }
        }
        finally
        {
            container.release( wagonManager );
View Full Code Here

TOP

Related Classes of org.apache.maven.artifact.manager.WagonManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.