2014-04-23 1 views
3

속성 :개미 Macrodef 내가 매개 변수로 호스트를 취 개미 스크립트 매크로 정의 사용

<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 문자열에 이미 가지고로 username과 host 사이의 '@'문자. 당

답변

3

: 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}을 (를) 사용하여 todir과 함께 사용하면 도움이되는지 확인할 수 있습니다.