git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274219 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -54,9 +54,10 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.ssh; | package org.apache.tools.ant.taskdefs.optional.ssh; | ||||
| import com.jcraft.jsch.Session; | |||||
| import com.jcraft.jsch.Channel; | import com.jcraft.jsch.Channel; | ||||
| import com.jcraft.jsch.ChannelExec; | import com.jcraft.jsch.ChannelExec; | ||||
| import com.jcraft.jsch.JSchException; | |||||
| import com.jcraft.jsch.Session; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| @@ -76,7 +77,7 @@ public abstract class AbstractSshMessage { | |||||
| this.session = session; | this.session = session; | ||||
| } | } | ||||
| protected Channel openExecChannel( String command ) { | |||||
| protected Channel openExecChannel( String command ) throws JSchException { | |||||
| ChannelExec channel = (ChannelExec) session.openChannel( "exec" ); | ChannelExec channel = (ChannelExec) session.openChannel( "exec" ); | ||||
| channel.setCommand( command ); | channel.setCommand( command ); | ||||
| @@ -97,7 +98,7 @@ public abstract class AbstractSshMessage { | |||||
| } while (b > 0); | } while (b > 0); | ||||
| } | } | ||||
| public abstract void execute() throws IOException; | |||||
| public abstract void execute() throws IOException, JSchException; | |||||
| public void setLogListener( LogListener aListener ) { | public void setLogListener( LogListener aListener ) { | ||||
| listener = aListener; | listener = aListener; | ||||
| @@ -201,7 +201,7 @@ public class Scp extends Task implements LogListener { | |||||
| if( failOnError ) { | if( failOnError ) { | ||||
| throw new BuildException(e); | throw new BuildException(e); | ||||
| } else { | } else { | ||||
| e.printStackTrace(); | |||||
| log("Caught exception: " + e.getMessage(), Project.MSG_ERR); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -317,7 +317,7 @@ public class Scp extends Task implements LogListener { | |||||
| } | } | ||||
| private Directory createDirectory( FileSet set ) { | private Directory createDirectory( FileSet set ) { | ||||
| DirectoryScanner scanner = set.getDirectoryScanner( project ); | |||||
| DirectoryScanner scanner = set.getDirectoryScanner( getProject() ); | |||||
| Directory root = new Directory( scanner.getBasedir() ); | Directory root = new Directory( scanner.getBasedir() ); | ||||
| String[] files = scanner.getIncludedFiles(); | String[] files = scanner.getIncludedFiles(); | ||||
| for (int j = 0; j < files.length; j++) { | for (int j = 0; j < files.length; j++) { | ||||
| @@ -76,7 +76,7 @@ public class ScpFromMessage extends AbstractSshMessage { | |||||
| this.isRecursive = recursive; | this.isRecursive = recursive; | ||||
| } | } | ||||
| public void execute() throws IOException { | |||||
| public void execute() throws IOException, JSchException { | |||||
| String command = "scp -f "; | String command = "scp -f "; | ||||
| if( isRecursive ) | if( isRecursive ) | ||||
| command += "-r "; | command += "-r "; | ||||
| @@ -54,8 +54,9 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.ssh; | package org.apache.tools.ant.taskdefs.optional.ssh; | ||||
| import com.jcraft.jsch.Session; | |||||
| import com.jcraft.jsch.Channel; | import com.jcraft.jsch.Channel; | ||||
| import com.jcraft.jsch.Session; | |||||
| import com.jcraft.jsch.JSchException; | |||||
| import java.io.*; | import java.io.*; | ||||
| import java.util.*; | import java.util.*; | ||||
| @@ -85,7 +86,7 @@ public class ScpToMessage extends AbstractSshMessage { | |||||
| this.remotePath = aRemotePath; | this.remotePath = aRemotePath; | ||||
| } | } | ||||
| public void execute() throws IOException { | |||||
| public void execute() throws IOException, JSchException { | |||||
| if( directoryList != null ) { | if( directoryList != null ) { | ||||
| doMultipleTransfer(); | doMultipleTransfer(); | ||||
| } | } | ||||
| @@ -95,7 +96,7 @@ public class ScpToMessage extends AbstractSshMessage { | |||||
| log("done.\n"); | log("done.\n"); | ||||
| } | } | ||||
| private void doSingleTransfer() throws IOException { | |||||
| private void doSingleTransfer() throws IOException, JSchException { | |||||
| String cmd = "scp -t " + remotePath; | String cmd = "scp -t " + remotePath; | ||||
| Channel channel = openExecChannel( cmd ); | Channel channel = openExecChannel( cmd ); | ||||
| try { | try { | ||||
| @@ -114,7 +115,7 @@ public class ScpToMessage extends AbstractSshMessage { | |||||
| } | } | ||||
| } | } | ||||
| private void doMultipleTransfer() throws IOException { | |||||
| private void doMultipleTransfer() throws IOException, JSchException { | |||||
| Channel channel = openExecChannel( "scp -d -t " + remotePath ); | Channel channel = openExecChannel( "scp -d -t " + remotePath ); | ||||
| try { | try { | ||||
| OutputStream out = channel.getOutputStream(); | OutputStream out = channel.getOutputStream(); | ||||