title: Ant sshexec task called from gradle doesn't show output
body: <p>I want to use Apache ant <code>sshexec</code> task in my gradle custom task. The problem is that this task doesn't work (output is not shown in console and sshexec action is not executed). This is how I use it:</p>
  
  <pre><code>configurations {
      sshexecAntTask
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      sshexecAntTask 'org.apache.ant:ant-jsch:1.7.0'
  }
  
  // ----------------------------------------------------
  
  import java.nio.file.FileAlreadyExistsException;
  import java.nio.file.Files
  
  class MyCustomTask extends DefaultTask {
  
      @TaskAction
      def build() {
          String command = ""
          command = 'cmd.exe /C mdir C:\\aadd'
          runSshCommand(command)
      }
  
      private void runSshCommand(String command) {
          String host = "host"
          String username = "username"
          String password = "password"
  
          ant.taskdef(name: 'sshexec', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec', classpath: project.configurations.sshexecAntTask.asPath)
          // this command is not executed; why?
          ant.sshexec(host: host, username: username, password: password, command: command, trust: 'true', failonerror: 'true')
      }
  
  }
  </code></pre>
  
  <p><strong>[EDIT]</strong>
  I've tested sshexec and those are my results:</p>
  
  <ol>
  <li>The command <code>cmd.exe /C echo test &gt; C:\testresult.txt</code> started from ant works correctly and output is returned to file.</li>
  <li>The command <code>cmd.exe /C echo test &gt; C:\testresult.txt</code> started from gradle works correctly and output is returned to file. Great!</li>
  <li>The command <code>cmd.exe /C echo test</code> started from ant works correctly and output is returned to stdout. <strong>!</strong></li>
  <li>The command <code>cmd.exe /C echo test</code> started from gradle works correctly but output is not returned to stdout. <strong>!</strong></li>
  <li>The command <code>cmd.exe /C mkdir C:\\\\Inetpub\\\\ftproot\\\\temp\\\\jakisnowykatalog</code> started from ant works correctly and directory is created (I need to use <code>\\\\</code> as path separator because <code>\\</code>, <code>\</code>, <code>/</code> doesn't work)</li>
  <li>The command <code>cmd.exe /C mkdir C:\\\\Inetpub\\\\ftproot\\\\temp\\\\jakisnowykatalog</code> started from gradle doesn't work and directory is not created.</li>
  </ol>
  
  <p>I should add that I want to connect with windows ssh server (not unix/mac) but I've also tested those commands with mac shh without success. Please help!</p>
  
  <p><strong>[Another edit]</strong>
  I've created groovy test code which uses jsch library to execute command and it works. I still don't know why ant task doesn't work.</p>
  
  <pre><code>import com.jcraft.jsch.*
  import java.util.Properties;
  
  private void jschTest() {
      Session session = null
      Channel channel = null
      try {
          JSch jsch = new JSch()
          session = jsch.getSession("host", "login", 22)
          session.setPassword("password")
          Properties config = new Properties()
          config.put("StrictHostKeyChecking", "no")
          session.setConfig(config)
          session.connect()
  
          String command = "cmd.exe /C mkdir C:\\gradledir"
          channel = session.openChannel("exec");
          ((ChannelExec)channel).setCommand(command);
          channel.connect()
      }
      catch (Exception e) {
          println e.getMessage()
      }
      finally {
          if (session!=null) {
              session.disconnect()
          }
          if (channel!=null) {
              channel.disconnect()
          }
      }
  }
  </code></pre>