ANT can't find specific libraries

2019-07-04 01:54发布

I am trying to use the SSHEXEC ANT task, which requires the JSCH library.

When I try to use an SSHEXEC task, I get the following:

BUILD FAILED
/home/www/test/build/build.xml:140: 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
        -/usr/share/ant/lib
        -/root/.ant/lib
        -a directory added on the command line with the -lib argument

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

I have placed jsch-0.1.50.jar (the latest) in /usr/share/ant/lib, /root/.ant/lib and even tried the following:

ant my-sshexec-target-name -lib /path/to/jsch-0.1.50.jar

And I keep getting the same error. I have also tried renaming the file to simply jsch.jar in all the same locations. Same result. What am I doing wrong here?

UPDATE

Also I ran ant -diagnostics and see this:

...
-------------------------------------------
 Tasks availability
-------------------------------------------
p4reopen : Not Available (the implementation class is not present)
image : Not Available (the implementation class is not present)
sshexec : Not Available (the implementation class is not present)
wlrun : Not Available (the implementation class is not present)
p4label : Not Available (the implementation class is not present)
p4revert : Not Available (the implementation class is not present)
p4submit : Not Available (the implementation class is not present)
scp : Not Available (the implementation class is not present)
p4change : Not Available (the implementation class is not present)
p4delete : Not Available (the implementation class is not present)
p4integrate : Not Available (the implementation class is not present)
rexec : Not Available (the implementation class is not present)
stlist : Not Available (the implementation class is not present)
telnet : Not Available (the implementation class is not present)
etc...

Note: sshexec : Not Available (the implementation class is not present)

What does that mean?

标签: java ant jsch
4条回答
对你真心纯属浪费
2楼-- · 2019-07-04 02:26

Set ANT_HOME to /usr/share/ant/

export ANT_HOME=/usr/share/ant/
查看更多
姐就是有狂的资本
3楼-- · 2019-07-04 02:32

I suspect it's not working because you need to specify the directory path, not the path to the jar file

ant my-sshexec-target-name -lib /path/to/where/you/put/the/extra/jarfiles

A better approach is to make it available to all builds by creating a $HOME/.ant/lib directory as follows:

A way to make your build work everywhere would be to include a bootstrap target that installs the jsch jar:

Finally you could use ivy to manage your dependencies, in a manner similar to Maven:

查看更多
相关推荐>>
4楼-- · 2019-07-04 02:36

on my Linux Mint Debian Edition 2 I faced the same problem: Wondering why "sshexec" task is stated as "Not available" when executing "ant -diagnostics".

Solution on my system was to install package "ant-optional" additionally. After that the usual solutions work as expected, like putting jsch.jar to ~/.ant/lib.

Regards

查看更多
Ridiculous、
5楼-- · 2019-07-04 02:48

Check whether the jar is there on the classpath by printing CLASSPATH varible in unix

查看更多
登录 后发表回答