我在ant脚本中定义了一个宏,它以主机为参数:
<macrodef name="upload">
<attribute name="host"/>
<sequential>
<echo>Uploading source code to @{host}...</echo>
<scp trust="true"
file="package/code.zip"
todir="${webserver.username}@@{host}:${webserver.upload_dir}"
keyfile="${webserver.keyfile}"
passphrase="" />
</sequential>
</macrodef>问题是我不知道如何在todir字符串中使用@{ host },因为它在用户名和主机之间已经有了一个“@”字符。
发布于 2014-04-23 07:40:28
https://ant.apache.org/manual/Tasks/macrodef.html,
The escape sequence @@ is used to escape @.
This allows @{x} to be placed in the text without substitution of x by using @@{x}.因此,在获得主机属性的值之前,尝试添加额外的“@”。
另外,您也可以尝试设置<property name="token" value="@"/>并使用${token}使用它来查看这是否有帮助
https://stackoverflow.com/questions/23237023
复制相似问题