我正在尝试使用SSHEXEC ANT task,这需要JSCH library。
当我尝试使用SSHEXEC
任务时,我得到以下内容:
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
我已将jsch-0.1.50.jar
(最新)放在/usr/share/ant/lib
,/root/.ant/lib
中,甚至尝试了以下内容:
ant my-sshexec-target-name -lib /path/to/jsch-0.1.50.jar
我一直得到同样的错误。我也尝试在所有相同的位置将文件重命名为jsch.jar
。结果相同。我在这里做错了什么?
更新
我也跑ant -diagnostics
并看到了这个:
...
-------------------------------------------
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...
注意: sshexec:不可用(实现类不存在)
这是什么意思?
答案 0 :(得分:1)
我怀疑它不起作用,因为你需要指定目录路径,而不是jar文件的路径
ant my-sshexec-target-name -lib /path/to/where/you/put/the/extra/jarfiles
更好的方法是通过创建$ HOME / .ant / lib目录使其可用于所有构建,如下所示:
让你的构建在任何地方工作的方法是包含一个安装jsch jar的引导目标:
最后,您可以使用ivy来管理您的依赖项,方式与Maven类似:
答案 1 :(得分:0)
通过在unix
中打印CLASSPATH变量来检查jar路径是否存在于类路径中答案 2 :(得分:0)
在我的Linux Mint Debian Edition 2上我遇到了同样的问题:想知道为什么在执行“ant -diagnostics”时“sshexec”任务被声明为“不可用”。
我的系统上的解决方案是另外安装包“ant-optional”。之后,通常的解决方案按预期工作,例如将jsch.jar放到〜/ .ant / lib。
此致
答案 3 :(得分:0)
将ANT_HOME设置为/ usr / share / ant /
export ANT_HOME=/usr/share/ant/