Ant自定义宏
Ant脚本project.xml 首先导入宏文件common.xml:
<import file="common.xml" />
<target name="任务:重新启动远端Resin服务器">
<rebootRemoteResin ssh.host="${ssh.host}" ssh.user="${ssh.user}" ssh.pwd="${ssh.pwd}" ssh.port="${ssh.port}" />
</target> |
宏文件定义如下:
<!-- 宏:重新启动远端Resin服务器 -->
<macrodef name="rebootRemoteResin">
<attribute name="ssh.host" />
<attribute name="ssh.user" />
<attribute name="ssh.pwd" />
<attribute name="ssh.port" />
<sequential>
<sshexec host="@{ssh.host}" username="@{ssh.user}" trust="true" password="@{ssh.pwd}" port="@{ssh.port}"
command="
resin/bin/httpd.sh -stop;
resin/bin/httpd.sh -start;
"/>
</sequential>
</macrodef> |