Hello all,
I have a multiproject build process which I am refactoring to use POGOs.
I am attempting to refactor some code which executes commands on a remote SLES server into one of these POGOs. Currently that code uses ant’s ‘SSHExec’ optional task (it has been configured in much the same way as is described here: http://www.gradle.org/docs/current/userguide/organizing_build_logic.html#sec:ant_optional_dependencies)
The POGO looks like this:
public class RemoteSLESCommand {
static def executeRemoteCommand ( final String pHost , final String pUsername , final String pPassword , final boolean pTrust , final boolean pFailOnError , final String pCommand ) {
println "executeRemoteCommand : pHost = $pHost ; pUsername = $pUsername ; pTrust = $pTrust ; pFailOnError = $pFailOnError ; pCommand = $pCommand "
( new AntBuilder() ).sshexec ( host
: pHost
, username
: pUsername
, password
: pPassword
, trust
: pTrust
, failonerror: pFailOnError
, command
: pCommand
)
}
static def createFolder ( final String pHost , final String pUsername , final String pPassword , final String pPathToRemoteFolder ) {
println "Creating remote folder: $pUsername@$pHost:$pPathToRemoteFolder"
executeRemoteCommand ( pHost , pUsername , pPassword , true , true , " mkdir -p $pPathToRemoteFolder " )
}
}
and it sits in the ‘buildSrc’ directory, like this:
<root>
build.gradle
buildSrc/src/main/groovy/RemoteSLESCommand.groovy
The POGO compiles without any problems, but when I create a task (in let’s say the build.gradle file which sits in the root directory) which attempts to invoke one of the methods provided by it, e.g.:
task x {
doLast {
RemoteSLESCommand.createFolder ( '<host>' , '<username>' , '<password>' , '$HOME/test' )
}
}
then I receive the following error at runtime:
* What went wrong:
Execution failed for task ':x'.
> Problem: failed to create task or type sshexec
Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not found.
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
That’s fine - but I don’t know how to make gradle see the missing JARs!
Can anyone provide an example of how to configure gradle such that it will find the JARs neccessary at runtime?
Thanks,
Andrew.