macrodef 直接解释是宏, 理解上能够是自定义标签或者自定义函数java
对于大型部署提升代码利用率web
为了方便理解经过如下代码:app
<macrodef name="macro-send-file"> <attribute name="host" /> <attribute name="toPath" /> <attribute name="file" /> <attribute name="userID" /> <attribute name="password" /> <sequential> <echo>@{userID}:@{password}@@@{host}:@{toPath}</echo> <scp verbose="false" trust="true" localFile="@{file}" todir="@{userID}:@{password}@@@{host}:@{toPath}" failonerror="true" /> <!-- sshexec trust="true" host="@{host}" username="@{userID}" password="@{password}" command="chmod -R u+rw,g+rwx @{toPath}/*.ear"/ --><sshexec trust="true" host="@{host}" username="@{userID}" password="@{password}" command="chown thangamm:wadmfsms @{toPath}/*.ear"/> <echo>Sent @{file} to @{host}:@{toPath}</echo> <!-- delete build dir --> <echo message="clean app project" /> <!-- after done, should clean the preparation folders but keep release folder --> <delete dir="${build.dir.app}${file.separator}${name.bin}" failonerror="false" /> <delete dir="${build.dir.app}${file.separator}${name.docs}" failonerror="false" /> <delete dir="${build.dir.app}${file.separator}${name.reports}" failonerror="false" /> <delete dir="${build.dir.app}${file.separator}${name.stage}" failonerror="false" /> <echo message="clean core project" /> <delete dir="${build.dir.core}" failonerror="false" /> <echo message="clean web project" /> <delete dir="${build.dir.web}" failonerror="false" /> </sequential> </macrodef>
<macrodef name="macro-send-file"> name 属性说明这个自定义宏的名字 经过这个name 来调用ssh
以下调用这个宏ide
<macro-send-file file="${file}" host="${autodeploy.host}" topath="${autodeploy.path}/${envName}" userid="${autodeploy.userID}" password="${autodeploy.password}" />
<attribute name="host" /> 表示宏的输入参数(至关于函数的参数)。在marcodef 中不一样经过${}来调用attrbute 的值而要经过@{}。例如显示传入参数userID 是什么经过<echo>@{userID}.函数
<sequential> 至关于函数的body 就是你这个能够调用经常使用ant tag 如何copy javac mkdir jar war 等ui
补充连接code