How do I load optional task sshexec into Ant in a no-configuration manner?

北城以北 提交于 2019-11-28 14:15:29

The sshexec task is built into ANT, you do not need to invoke a taskdef operation to use it. All that's missing is the jsch jar.

This can installed using a bootstrap target as follows (from Maven Central):

<target name="bootstrap" description="Install missing jars">
    <mkdir dir="${user.home}/.ant/lib"/>
    <get src="http://search.maven.org/remotecontent?filepath=com/jcraft/jsch/0.1.48/jsch-0.1.48.jar" dest="${user.home}/.ant/lib/jsch.jar"/>
</target>

This target only needs to be run once, after which the ANT sshexec task will work as expected on the developer's PC.

Update

If you don't want to download jars another mechanism to pass the location of ANT libraries from the command line as follows:

ant -lib /path/to/project/lib/dir ...

For more details on ANT library management, I refer you to the ANT manual

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>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!