Ant’s SCP Task
Problem: You have an application whose source is going to be distributed with an Ant build script, either internally or publicly and the build script uses the SCP task. The SCP task is a standard Ant task, ie you don’t have to (can’t) do a <taskdef> to load it’s classes to use it. The standard Ant distribution, however, does not include the JSch.jar library required by the task. Normally you would just download the jar and add it to your Ant instance’s /lib directory, however if you are distributing the build file, you cannot expect that everyone will have that included. This is especially important for those users who just want to type “ant deploy” and have the application up and running.
Solution: The best solution I’ve found for this is to use a custom classloader task, to load the JSch classes before you need the SCP task. JTools’ Classloader task works great for this. Simply include the JSch library with they libraries for your other custom ant tasks, then in the build file set the SCP task like this:
<taskdef resource="net/jtools/classloadertask/antlib.xml"
classpathref="${classpath}"/>
<classloader loader="project" classpath="${internal.lib.dir}/js*.jar"/>
<scp file="myfile.txt" todir="user:password@somehost:/home/chuck"/>
This can save those trying to deploy your application a lot of grief for very little overhead.


Thanks! Helped me out.