Package org.apache.maven.wagon

Examples of org.apache.maven.wagon.Wagon


        stagingSiteURL = getStagingSiteURL( project, reactorProjects, stagingSiteURL );
        getLog().info( "Using this URL for staging: " + stagingSiteURL );

        Repository repository = new Repository( stagingRepositoryId, stagingSiteURL );

        Wagon wagon;
        try
        {
            wagon = wagonManager.getWagon( repository );
            SiteDeployMojo.configureWagon( wagon, stagingRepositoryId, settings, plexusContainer, getLog() );
            wagon.connect( repository );
        }
        catch ( UnsupportedProtocolException e )
        {
            throw new MojoExecutionException( "Unsupported protocol: '" + repository.getProtocol() + "'", e );
        }
        catch ( WagonConfigurationException e )
        {
            throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol() + "'", e );
        } catch (AuthenticationException e)
        {
            throw new MojoExecutionException( "AuthenticationException : Unable to connect Wagon to repository : '" + repository.getProtocol() + "'", e );
        }
        catch ( ConnectionException e )
        {
            throw new MojoExecutionException( "Unable to connect Wagon to repository : '" + repository.getProtocol() + "'", e );
        }

        if ( !wagon.supportsDirectoryCopy() )
        {
            throw new MojoExecutionException(
                "Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying" );
        }
      
        try
        {
            Debug debug = new Debug();
           

            wagon.addSessionListener( debug );

            wagon.addTransferListener( debug );

            /*
            ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
            if ( proxyInfo != null )
            {
                wagon.connect( repository, wagonManager.getAuthenticationInfo( stagingRepositoryId ), proxyInfo );
            }
            else
            {
                wagon.connect( repository, wagonManager.getAuthenticationInfo( stagingRepositoryId ) );
            }
            */
            wagon.connect( repository );
            wagon.putDirectory( new File( stagingDirectory, getStructure( project, false ) ), "." );

            getLog().debug( "putDirectory end ok " );
            if ( chmod && wagon instanceof CommandExecutor )
            {
                CommandExecutor exec = (CommandExecutor) wagon;
                exec.executeCommand( "chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir() );
            }
        }
        catch ( ResourceDoesNotExistException e )
        {
            throw new MojoExecutionException( "Error uploading site", e );
        }
        catch ( TransferFailedException e )
        {
            throw new MojoExecutionException( "Error uploading site", e );
        }
        catch ( AuthorizationException e )
        {
            throw new MojoExecutionException( "Error uploading site", e );
        }
        catch ( ConnectionException e )
        {
            throw new MojoExecutionException( "Error uploading site", e );
        }
        catch ( AuthenticationException e )
        {
            throw new MojoExecutionException( "Error uploading site", e );
        }
        catch ( CommandExecutionException e )
        {
            throw new MojoExecutionException( "Error uploading site", e );
        }
        finally
        {
            try
            {
                wagon.disconnect();
            }
            catch ( ConnectionException e )
            {
                getLog().error( "Error disconnecting wagon - ignored", e );
            }
View Full Code Here


     * @throws ConnectionException
     * @throws AuthenticationException
     */
    public void testNullFileWagon() throws ConnectionException, AuthenticationException
    {
        Wagon wagon = new FileWagon();
        Resource resource = new Resource();
        resource.setContentLength( 100000 );
        Repository repository = new Repository();
        wagon.connect( repository );
    }
View Full Code Here

    public void testResourceExists()
        throws Exception
    {
        String url = "file://" + getBasedir();
       
        Wagon wagon = new FileWagon();
        Repository repository = new Repository( "someID", url );
        wagon.connect( repository );
       
        assertTrue( wagon.resourceExists( "target" ) );
        assertTrue( wagon.resourceExists( "target/" ) );
        assertTrue( wagon.resourceExists( "pom.xml" ) );
       
        assertFalse( wagon.resourceExists( "pom.xml/" ) );
       
        wagon.disconnect();
    }
View Full Code Here

        addConnectors( server );
        server.start();

        try
        {
            Wagon wagon = getWagon();

            Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );

            File sourceFile = new File( localRepositoryPath + "/gzip" );

            sourceFile.deleteOnExit();

            String resName = "gzip-res.txt";
            String sourceContent = writeTestFileGzip( sourceFile, resName );

            wagon.connect( testRepository );

            File destFile = FileTestUtils.createUniqueFile( getName(), getName() );

            destFile.deleteOnExit();

            wagon.get( "gzip/" + resName, destFile );

            wagon.disconnect();

            String destContent = FileUtils.fileRead( destFile );

            assertEquals( sourceContent, destContent );
        }
View Full Code Here

            }
            tempIndexDirectory.mkdirs();
            tempIndexDirectory.deleteOnExit();
            String baseIndexUrl = indexingContext.getIndexUpdateUrl();

            final Wagon wagon = wagonFactory.getWagon( new URL( this.remoteRepository.getUrl() ).getProtocol() );
            setupWagonReadTimeout( wagon );

            // TODO transferListener
            wagon.addTransferListener( new DownloadListener() );
            ProxyInfo proxyInfo = null;
            if ( this.networkProxy != null )
            {
                proxyInfo = new ProxyInfo();
                proxyInfo.setHost( this.networkProxy.getHost() );
                proxyInfo.setPort( this.networkProxy.getPort() );
                proxyInfo.setUserName( this.networkProxy.getUsername() );
                proxyInfo.setPassword( this.networkProxy.getPassword() );
            }
            AuthenticationInfo authenticationInfo = null;
            if ( this.remoteRepository.getUserName() != null )
            {
                authenticationInfo = new AuthenticationInfo();
                authenticationInfo.setUserName( this.remoteRepository.getUserName() );
                authenticationInfo.setPassword( this.remoteRepository.getPassword() );
            }
            wagon.connect( new Repository( this.remoteRepository.getId(), baseIndexUrl ), authenticationInfo,
                           proxyInfo );

            File indexDirectory = indexingContext.getIndexDirectoryFile();
            if ( !indexDirectory.exists() )
            {
View Full Code Here

    private void deploy( final File directory, final Repository repository )
        throws MojoExecutionException
    {
        // TODO: work on moving this into the deployer like the other deploy methods
        final Wagon wagon = getWagon( repository, wagonManager );

        try
        {
            configureWagon( wagon, repository.getId(), settings, container, getLog() );
        }
        catch ( TransferFailedException e )
        {
            throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol() + "'", e );
        }

        try
        {
            final ProxyInfo proxyInfo;
            if ( !isMaven3OrMore() )
            {
                proxyInfo = getProxyInfo( repository, wagonManager );
            }
            else
            {
                try
                {
                    SettingsDecrypter settingsDecrypter = container.lookup( SettingsDecrypter.class );

                    proxyInfo = getProxy( repository, settingsDecrypter );
                }
                catch ( ComponentLookupException cle )
                {
                    throw new MojoExecutionException( "Unable to lookup SettingsDecrypter: " + cle.getMessage(), cle );
                }
            }

            push( directory, repository, wagon, proxyInfo, siteTool.getAvailableLocales( locales ),
                  getDeployModuleDirectory() );

            if ( chmod )
            {
                chmod( wagon, repository, chmodOptions, chmodMode );
            }
        }
        finally
        {
            try
            {
                wagon.disconnect();
            }
            catch ( ConnectionException e )
            {
                getLog().error( "Error disconnecting wagon - ignored", e );
            }
View Full Code Here

    }

    private Wagon getWagon( final Repository repository, final WagonManager manager )
        throws MojoExecutionException
    {
        final Wagon wagon;

        try
        {
            wagon = manager.getWagon( repository );
        }
        catch ( UnsupportedProtocolException e )
        {
            String shortMessage = "Unsupported protocol: '" + repository.getProtocol() + "' for site deployment to "
                + "distributionManagement.site.url=" + repository.getUrl() + ".";
            String longMessage =
                "\n" + shortMessage + "\n" + "Currently supported protocols are: " + getSupportedProtocols() + ".\n"
                    + "    Protocols may be added through wagon providers.\n" + "    For more information, see "
                    + "http://maven.apache.org/plugins/maven-site-plugin/examples/adding-deploy-protocol.html";

            getLog().error( longMessage );

            throw new MojoExecutionException( shortMessage );
        }
        catch ( TransferFailedException e )
        {
            throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol() + "'", e );
        }

        if ( !wagon.supportsDirectoryCopy() )
        {
            throw new MojoExecutionException(
                "Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying" );
        }
View Full Code Here

    @Test
    public void testLookupSuccessiveWagons()
        throws Exception
    {

        Wagon first = factory.getWagon( "wagon#file" );
       
        Wagon second = factory.getWagon( "wagon#file" );

        // ensure we support only protocol name too
        Wagon third = factory.getWagon( "file" );
       
        assertNotSame( first, second );

        assertNotSame( first, third );
    }
View Full Code Here

        try
        {
            // with sisu inject bridge hint is file or http
            // so remove wagon#
            protocol = StringUtils.remove( protocol, "wagon#" );
            Wagon wagon = plexusSisuBridge.lookup( Wagon.class, protocol );
            wagon.addTransferListener( debugTransferListener );
            return wagon;
        }
        catch ( PlexusSisuBridgeException e )
        {
            throw new WagonFactoryException( e.getMessage(), e );
View Full Code Here

        File tmpResource = null;

        File workingDirectory = createWorkingDirectory( repository );
        try
        {
            Wagon wagon = null;
            try
            {
                RepositoryURL repoUrl = remoteRepository.getURL();
                String protocol = repoUrl.getProtocol();
                wagon = wagonFactory.getWagon( "wagon#" + protocol );
                if ( wagon == null )
                {
                    throw new ProxyException( "Unsupported target repository protocol: " + protocol );
                }

                boolean connected = connectToRepository( connector, wagon, remoteRepository );
                if ( connected )
                {
                    tmpResource = new File( workingDirectory, resource.getName() );
                    transferSimpleFile( wagon, remoteRepository, remotePath, repository, resource, tmpResource );

                    // TODO: these should be used to validate the download based on the policies, not always downloaded
                    // to
                    // save on connections since md5 is rarely used
                    tmpSha1 =
                        transferChecksum( wagon, remoteRepository, remotePath, repository, resource, workingDirectory,
                                          ".sha1" );
                    tmpMd5 =
                        transferChecksum( wagon, remoteRepository, remotePath, repository, resource, workingDirectory,
                                          ".md5" );
                }
            }
            catch ( NotFoundException e )
            {
                urlFailureCache.cacheFailure( url );
                throw e;
            }
            catch ( NotModifiedException e )
            {
                // Do not cache url here.
                throw e;
            }
            catch ( ProxyException e )
            {
                urlFailureCache.cacheFailure( url );
                throw e;
            }
            catch ( WagonFactoryException e )
            {
                throw new ProxyException( e.getMessage(), e );
            }
            finally
            {
                if ( wagon != null )
                {
                    try
                    {
                        wagon.disconnect();
                    }
                    catch ( ConnectionException e )
                    {
                        log.warn( "Unable to disconnect wagon.", e );
                    }
View Full Code Here

TOP

Related Classes of org.apache.maven.wagon.Wagon

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.