Problem when running ant task that calls sshexec from gradle

(Daniel M) #1

We are trying to convert our project to use Gradle and as an initial step we simply imported our build.xml on our build.graddle file and called the appropriate target.

We are using the eclipse gradle plugin to run it, and for the most part it seems to work, but we are hitting an issue when the target executed uses the ant task sshexec:

<target name="copy-files">
		<sshexec host="${}" username="${linux.username}" keyfile="${linux.password}"
             command="mkdir -p ${linux.release.dir}" trust="true" failonerror="false"/>
		<scp todir="${linux.username}@${}:${linux.release.dir}" keyfile="${linux.password}" trust="true">
			<fileset dir="${}">
				<include name="**/*.*"/>

our build.gradle file looks like:

// Apply the java plugin to add support for Java
apply plugin: 'java'
ant.importBuild 'build.xml' 

when I run this i get:

Caused by: build.xml:65: Problem: failed to create task or type sshexec
Cause: the class was not found.
This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in

From what I read online I am supposed to add this library as part of my dependencies. This is what I currently have on our build.gradle file but I have tried other different formats but all of them return the same error:

repositories {
    // Use 'jcenter' for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.

configurations {

dependencies {
    antClasspath files('lib/ssh/jsch-0.1.42.jar')

The jsch library is currently sitting on a subfolder of the project in my local PC.

I have tried replacing “antClasspath” with “compile” instead and get the same error.

All the posts similar to my issue that I have seen online haven’t resolve my problem.
Any help would be appreciated.