javamavengroovygroovy-grape

Can I avoid using Grape to load modules in Groovy?


I am writing my first automation script in groovy and I've hit a roadblock. While making use of the AntBuilder class to run sshexec() I run into the following error:

: 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

So far the best solution I've found for this is to use

Grape.grab(group : "com.jcraft", module : "jsch", classLoader : this.class.classLoader.rootLoader)
Grape.grab(group:"ant", module:"ant-jsch", classLoader:this.class.classLoader.rootLoader)

in order to load the required modules. However, I would like to eliminate the lag time of Grape downloading the jars from the remote Maven repository.

Is there a way to download and save modules for future use, perhaps in the JAVA_PATH or something to that effect?


Solution

  • Adding the required jars to %ANT_HOME% and %GROOVY_HOME% wasn't working.

    The solution is to put the jars under %USERPROFILE%.groovy\lib - after which the Grape calls are no longer necessary. Hopefully this is useful to others with the same issue.

    Thanks to Dave for getting me on the right track.