tags:

views:

61

answers:

1

build.xml contains <scp> and <sshexec> tasks, so I provide jsch.jar and other libraries in the same directory together with build.xml.

The following taskdef:

    <taskdef name="scp"
        classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp"
    classpath="WebContent/WEB-INF/lib/jsch-0.1.43.jar" />

throws an error

A class needed by class org.apache.tools.ant.taskdefs.optional.ssh.Scp
cannot be found: com/jcraft/jsch/UserInfo

I cannot modify the standard Ant installation (e.g. put jsch.jar in ant lib directory, or remove ant-jsch.jar), or add command-line flags, or modify system environment variables, etc.: the script has to run with default Ant on different systems.

I'm actually reposting the question originally asked here: http://ant.1045680.n5.nabble.com/specifying-location-of-an-external-library-within-build-xml-td1344969.html

but could not get the answer about classloader to work.

A: 

Create a path reference and then use it in you task definition

<path id="ssh.path">
   <pathelement location="${lib1.dir}/helloworld.jar"/>
   <fileset dir="${lib2.dir}">
       <include name="*.jar"/>
   </fileset>
</path>

<taskdef name="mytask" classname="org.mytask" classpathref="ssh.path" />
Mark O'Connor