【问题标题】:Ant Macrodef attribute usageAnt Macrodef 属性用法
【发布时间】:2014-06-07 20:33:45
【问题描述】:

我在 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},因为它在用户名和主机之间已经有一个“@”字符。

【问题讨论】:

    标签: ant scp


    【解决方案1】:

    每个: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}.
    

    所以尝试在获取主机属性值之前添加额外的“@”。

    您也可以尝试设置 &lt;property name="token" value="@"/&gt; 并将其与 todir 和 ${token} 一起使用,看看是否有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多