You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by asgeir <vi...@gmail.com> on 2006/11/04 00:45:44 UTC

specifying location of an external library within build.xml

Hello All,

Is there a way to specify the location of an external library for an
optional task (jsch.jar in my case) from within build.xml, or to change the
order of classes being loaded?

Here's what I'm trying to do:
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 works fine with Ant 1.5: build.xml checks for current ant
version and if it is 1.5 it does <taskdef name="scp"> with custom classpath
containing ant-jsch.jar (from 1.6), jsch.jar, etc.

Class org.apache.tools.ant.taskdefs.optional.ssh.Scp loaded from ant loader
Finding class com.jcraft.jsch.UserInfo
Class com.jcraft.jsch.UserInfo loaded from ant loader

However, the same build fails with Ant 1.6, with or without <taskdef>:

Class org.apache.tools.ant.taskdefs.optional.ssh.Scp loaded from parent
loader (parentFirst)
A class needed by class
org.apache.tools.ant.taskdefs.optional.ssh.Scpcannot 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. Unfortunately, currently it only runs with Ant 1.5 and
not 1.6.

Thanks in advance!

Re: specifying location of an external library within build.xml

Posted by Peter Reilly <pe...@gmail.com>.
On 11/3/06, asgeir <vi...@gmail.com> wrote:
> Hello All,
>
> Is there a way to specify the location of an external library for an
> optional task (jsch.jar in my case) from within build.xml, or to change the
> order of classes being loaded?
You can use the classloader task
from:
http://enitsys.sourceforge.net/ant-classloadertask/

Peter

>
> Here's what I'm trying to do:
> 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 works fine with Ant 1.5: build.xml checks for current ant
> version and if it is 1.5 it does <taskdef name="scp"> with custom classpath
> containing ant-jsch.jar (from 1.6), jsch.jar, etc.
>
> Class org.apache.tools.ant.taskdefs.optional.ssh.Scp loaded from ant loader
> Finding class com.jcraft.jsch.UserInfo
> Class com.jcraft.jsch.UserInfo loaded from ant loader
>
> However, the same build fails with Ant 1.6, with or without <taskdef>:
>
> Class org.apache.tools.ant.taskdefs.optional.ssh.Scp loaded from parent
> loader (parentFirst)
> A class needed by class
> org.apache.tools.ant.taskdefs.optional.ssh.Scpcannot 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. Unfortunately, currently it only runs with Ant 1.5 and
> not 1.6.

>
> Thanks in advance!
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: specifying location of an external library within build.xml

Posted by Jacob Kjome <ho...@visi.com>.
Can you add your libraries to ${user.home}/.ant/lib?  That's 
equivalent to adding jars to ${ant.home}/lib.  There is another 
option.  You can avoid all the classloading issues and simply use a 
native SCP executable.  Do something like this...


                 <exec dir="." executable="${scp}" failonerror="true">
                     <arg path="${localfile}"/>
                     <arg value="${serverurl}"/>
                 </exec>

...where ${scp} is the name of the SCP executable that is on the 
system Path.  You can parameterize this by loading a 
${user.home}/build.properties file in your build.  So, no matter what 
system you are on and no matter what the name of the SCP executable 
is, it will work as long as the user configures it in that common 
property file.

Jake

At 05:45 PM 11/3/2006, you wrote:
 >Hello All,
 >
 >Is there a way to specify the location of an external library for an
 >optional task (jsch.jar in my case) from within build.xml, or to change the
 >order of classes being loaded?
 >
 >Here's what I'm trying to do:
 >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 works fine with Ant 1.5: build.xml checks for current ant
 >version and if it is 1.5 it does <taskdef name="scp"> with custom classpath
 >containing ant-jsch.jar (from 1.6), jsch.jar, etc.
 >
 >Class org.apache.tools.ant.taskdefs.optional.ssh.Scp loaded from ant loader
 >Finding class com.jcraft.jsch.UserInfo
 >Class com.jcraft.jsch.UserInfo loaded from ant loader
 >
 >However, the same build fails with Ant 1.6, with or without <taskdef>:
 >
 >Class org.apache.tools.ant.taskdefs.optional.ssh.Scp loaded from parent
 >loader (parentFirst)
 >A class needed by class
 >org.apache.tools.ant.taskdefs.optional.ssh.Scpcannot 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. Unfortunately, currently it only runs with Ant 1.5 and
 >not 1.6.
 >
 >Thanks in advance!
 >
 > 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org