Package org.apache.maven.wagon

Examples of org.apache.maven.wagon.CommandExecutionException


        {
            privateKey = ScpHelper.getPrivateKey( authenticationInfo );
        }
        catch ( FileNotFoundException e )
        {
            throw new CommandExecutionException( e.getMessage(), e );
        }
        Commandline cl = createBaseCommandLine( putty, sshExecutable, privateKey );

        int port =
            repository.getPort() == WagonConstants.UNKNOWN_PORT ? ScpHelper.DEFAULT_SSH_PORT : repository.getPort();
        if ( port != ScpHelper.DEFAULT_SSH_PORT )
        {
            if ( putty )
            {
                cl.createArg().setLine( "-P " + port );
            }
            else
            {
                cl.createArg().setLine( "-p " + port );
            }
        }

        if ( sshArgs != null )
        {
            cl.createArg().setLine( sshArgs );
        }

        String remoteHost = this.buildRemoteHost();

        cl.createArg().setValue( remoteHost );

        cl.createArg().setValue( command );

        fireSessionDebug( "Executing command: " + cl.toString() );

        try
        {
            CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
            int exitCode = CommandLineUtils.executeCommandLine( cl, out, err );
            Streams streams = new Streams();
            streams.setOut( out.getOutput() );
            streams.setErr( err.getOutput() );
            fireSessionDebug( streams.getOut() );
            fireSessionDebug( streams.getErr() );
            if ( exitCode != 0 )
            {
                if ( !ignoreFailures || exitCode == SSH_FATAL_EXIT_CODE )
                {
                    throw new CommandExecutionException( "Exit code " + exitCode + " - " + err.getOutput() );
                }
            }
            return streams;
        }
        catch ( CommandLineException e )
        {
            throw new CommandExecutionException( "Error executing command line", e );
        }
    }
View Full Code Here

TOP

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

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.