Eclipse, ANT and sshexec
It took me quite a while to figure out how to make eclipse work with sshexec targets on ant build files. Turns out it was quite easy and even uses the cached identity used for cvs operations. Quite handy. The way I made it work was to tell the ant builder to make use of the jsch jar included in eclipse for use by the cvs plugin.
- Open
Window -> Preferences - Select
Ant -> Runtimeon the left side - In the classpath tab, select
Ant Home Entries - Click on the
Add External JARs...button - Navigate to your eclipse installation, then select
eclipse/plugins/ org.eclipse.team.cvs.ssh2_3.1.0/jsch-0.1.18.jar - Click
okayto confirm the file selection - Click
okayto close the preferences dialog - Run your buildfile with
sshexecand/orscptasks.
It’s that easy. The specific version number of the cvs/ssh plugin and the jsch jar may differ, but it should still work.

December 18th, 2005 at 12:04 pm
nice one.
If you keep getting the error about authentication, you have to turn on PasswordAuthentication in the ssh server config file.
July 27th, 2006 at 1:17 pm
I followed the instructions for Eclipse, Ant, and sshexec.
The name of the jar that I found in my Eclipse plugins was identical to the one in your instructions. I am running Eclipse 3.1 on a RHEL4 Linux box. I do not use cvs.
When I attempt to run sshexec from an Eclipse project with the following build.xml target:
I invariably get this error:
com.jcraft.jsch.JSchException: java.lang.ArrayIndexOutOfBoundsException: 1024
This also occurs if I use an explicit password rather than
a keyfile.
What am I missing?
July 30th, 2006 at 3:43 am
I’ve seen this error with ant before, it’s confusing, but it comes from having a semantically invalid scp target in the build.xml
In my case, I was using *both* the remoteToDir and remoteToFile in an attempt to rename a file at the destination. Turns out that the remoteToFile can contain the remoteToDir as a prefix. If you have both present, then what should simply be noticed as an illogical combination of attributes is instead turned into an obscure error.
Double, and triple check that you have a well formed scp task. However, the documentation for scp does *not* make it clear what valid combinations there are.