I am trying to write a custom gradle plugin that provides ssh/scp functionality by wrapping the AntBuilder.sshexec and AntBuilder.scp in gradle tasks since we use them in many different builds and its a pain to redefine the ant task in every build.
Everything seems to be working as far as applying the plugin and that structure, but when I try to invoke AntBuilder, I get an exception that the extra ant classes (ant-jsch) are not found. It’s like the classloaders are seperate and none of the transitive dependencies are getting picked up by the buildscript. I even built the custom plugin as a fatjar so the classes would have to be on the classpath, but got the same error.
apply plugin: 'base'
apply plugin: edu.pdx.cs.rylarson.RemotePlugin
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath group: 'co.ryanlarson', name: 'gradle-remote', version: '+'
}
}
task testSsh(type: edu.pdx.cs.rylarson.ssh.SshTask) {
host = "hostname"
user = "root"
password = "toor"
trust = true
command = "uname"
}
I get the following error when I try to run the testSssh task:
* What went wrong:
Execution failed for task ':testSsh'.
> Problem: failed to create task or type sshexec
Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not fo
und.
This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
-ANT_HOME\lib
-the IDE Ant configuration dialogs
Do not panic, this is a common problem.
The commonest cause is a missing JAR.
This is not a bug; it is a configuration problem
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
This is the build for the plugin itself, the POM has the transitive dependencies:
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'maven'
group = 'co.ryanlarson'
version = '0.1.0'
repositories {
mavenCentral()
}
dependencies {
compile gradleApi()
compile localGroovy()
runtime 'org.apache.ant:ant-jsch:+'
runtime 'com.jcraft:jsch:+'
}
task wrapper(type: Wrapper) {
gradleVersion = '1.6'
}
task sourcesJar(type: Jar) {
from sourceSets.main
classifier = 'sources'
}
//jar {
//
doFirst {
//
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
//
}
//
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
//}
artifacts {
archives jar
archives sourcesJar
}
I have commented out the jar closure but that is what I used to build the fat jar with the same results.