Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何以无配置的方式将可选任务sshexec加载到Ant中?_Java_Ant_Ssh_Jsch - Fatal编程技术网

Java 如何以无配置的方式将可选任务sshexec加载到Ant中?

Java 如何以无配置的方式将可选任务sshexec加载到Ant中?,java,ant,ssh,jsch,Java,Ant,Ssh,Jsch,我使用的是sshexec,它依赖于jsch-0.1.48.jar。我不能把它放在ant/lib目录中,因为其他希望使用相同构建脚本的用户必须在他们的机器上进行配置才能这样做 我想做的是能够在项目中引用jsch-0.1.48.jar。目前,我把它放在project/libs目录中,我正在尝试类似的方法: <property name="lib" location="lib"/> <taskdef name="sshexec" classname="org.apache.tool

我使用的是sshexec,它依赖于jsch-0.1.48.jar。我不能把它放在ant/lib目录中,因为其他希望使用相同构建脚本的用户必须在他们的机器上进行配置才能这样做

我想做的是能够在项目中引用jsch-0.1.48.jar。目前,我把它放在project/libs目录中,我正在尝试类似的方法:

<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>
该任务内置于ANT中,您无需调用taskdef操作即可使用它。缺少的只是jsch jar

这可以使用引导目标安装,如下所示:

有关ANT库管理的更多详细信息,请参阅

任务内置于ANT中,您无需调用taskdef操作即可使用它。缺少的只是jsch jar

这可以使用引导目标安装,如下所示:


有关ANT库管理的更多详细信息,请参阅我的项目附带的JSCHJAR。因此,我没有下载它,而是将它复制到ant库中。构建将在第一次运行时失败,这对我来说是很好的。它将第二次成功,因为jar将在库中,并且将在开始时加载

<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>

JSCHJAR与我的项目打包在一起。因此,我没有下载它,而是将它复制到ant库中。构建将在第一次运行时失败,这对我来说是很好的。它将第二次成功,因为jar将在库中,并且将在开始时加载

<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>

通常,签入二进制jar文件是个坏主意。。。事情很快就会失控,尤其是使用DVCS。最好按照@Mark O'Conner指定的方式使用ivy或http获取它。通常,签入二进制jar文件是个坏主意。。。事情很快就会失控,尤其是使用DVCS。最好按照@Mark O'Conner的指定使用ivy或http来获取它。
ant -lib /path/to/project/lib/dir ...
<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>