如何加载可选任务sshexec到蚂蚁在没有配置的方式? [英] How do I load optional task sshexec into Ant in a no-configuration manner?

查看:225
本文介绍了如何加载可选任务sshexec到蚂蚁在没有配置的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用sshexec,这取决于jsch-0.1.48.jar。我不能只是它放入蚂蚁/ lib目录,因为希望使用相同的构建脚本的其他用户将不得不让自己的机器上的配置,才可以这样做。

我想要做的就是能够引用jsch-0.1.48.jar作为该项目的一部分。目前,我有它坐在工程/ libs目录,我想是这样的:

 <属性名=LIB位置=lib目录/><的taskdef NAME =sshexec类名=org.apache.tools.ant.taskdefs.optional.ssh.SSHExec>
  <&类路径GT;
    < pathelement位置=$ {}的lib /jsch-0.1.48.jar/>
  < /类路径>
< /&的taskdef GT;<目标名称=sshcmd描述=ssh命令>
    < sshexec主机=X.X.X.X用户名=USER密码=PASS命令=CMD信任=真/>
< /目标与GT;

但是,这不工作:

  C:\\ dev的\\干线\\项目:>蚂蚁sshcmd
构建文件:C:\\ dev的\\干线\\项目\\ build.xml文件构建失败
C:\\ dev的\\干线\\项目\\的build.xml:275:用的taskdef类需要一个类org.apache.tools.ant.taskdefs.optional.ssh.SSHExec无法找到:COM / jcraft / jsch /记录器
使用ClassLoader AntClassLoader [C:\\ dev的\\干线\\项目\\ LIB \\ jsch-0.1.48.jar]总时间:0秒


解决方案

该jsch罐包装与我的项目。因此,而不是下载它,我复制它变成蚂蚁库。构建将失败第一次运行时,这是很好的,我的目的。它会成功,第二次,因为罐子会在图书馆,并会在启动时被加载。

 <目标名称=jschset描述=设置罐子>
    <复制文件=$ {}的lib /jsch-0.1.48.jarTOFILE =$ {} ant.home /lib/jsch-0.1.48.jar/>
< /目标与GT;

I am using sshexec, which depends on jsch-0.1.48.jar. I can't just put that into the ant/lib directory because other users wishing to use the same build script will have to make a configuration on their machine before they can do so.

What I want to do is to be able to reference jsch-0.1.48.jar as part of the project. Currently, I have it sitting in project/libs directory and I am trying something like:

<property name="lib" location="lib"/>

<taskdef name="sshexec" classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec">
  <classpath>
    <pathelement location="${lib}/jsch-0.1.48.jar"/>  
  </classpath>
</taskdef> 

<target name="sshcmd" description="ssh command">    
    <sshexec host="X.X.X.X" username="USER" password="PASS" command="cmd" trust="true"/>
</target>

But that's not working:

C:\dev\trunk\project:>ant sshcmd
Buildfile: C:\dev\trunk\project\build.xml

BUILD FAILED
C:\dev\trunk\project\build.xml:275: taskdef A class needed by class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec cannot be found: com/jcraft/jsch/Logger
using the classloader AntClassLoader[C:\dev\trunk\project\lib\jsch-0.1.48.jar]

Total time: 0 seconds

解决方案

The jsch jar is packaged with my project. So instead of downloading it, I am copying it into the ant library. The build will fail the first time it is run, which is fine for my purposes. It will succeed the second time because the jar will be in the library and would be loaded at start.

<target name="jschset" description="Set the jar">   
    <copy file="${lib}/jsch-0.1.48.jar" tofile="${ant.home}/lib/jsch-0.1.48.jar"/>
</target>

这篇关于如何加载可选任务sshexec到蚂蚁在没有配置的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆