2012-02-09 2 views
1

하나의 대상에서 Ant 파일의 "variable"을 변경하고 다른 대상에서 변경 내용을 확인하고 싶습니다.전역 변수 수정 Ant

<variable name="foo" value="hello" /> 
<target name="print-me"> 
    <echo message="${foo}" /> 
    <antcall target="change-me" /> 
    <echo message="${foo}" /> 
</target> 

<target name="change-me"> 
    <variable name="foo" value="world" /> 
</target> 

나는 인쇄를 원하는 반면 '안녕하세요, 세계, 그것은 사용 하나

+1

가능한 복제본 [개미에 속성을 덮어 쓰는 방법] (http://stackoverflow.com/questions/1866729/how-to-over-write-the-property-inantant) – oers

+0

잊어 버렸습니다. unset = "true"[변수 작업] (http://ant-contrib.sourceforge.net/tasks/tasks/variable_task.html) – oers

답변

2

'안녕, 안녕 '인쇄 : Oers로

<target name="change-me"> 
    <variable name="foo" unset="true"/> 
    <variable name="foo" value="world"/> 
</target> 

이미 그의 주석에서 언급 궁금한 점이 있거나 let taskAnt addon Flaka 인 직접 접근 방식을 사용하는
:

<project xmlns:fl="antlib:it.haefelinger.flaka"> 

... 
<!-- overwrite any existing property or userproperty 
    (those properties defined on the commandline via -Dfoo=bar ..) --> 
<fl:let> foo ::= 'world'</fl:let> 

... 
</project> 
+0

변수 unset은 변수를 대상 외부에 적용하지 않습니다. 즉이 변경 사항을 추가하면 "print-me"대상의 인쇄물이 여전히 "안녕하세요"를 인쇄합니다 ...이 부가 기능을 사용해보고 알려 드리겠습니다. 감사! –

-1

ant-contrib 태그를 사용하는 경우 작동합니다.

+0

답을 설명하기 위해 예제를 제시 할 수 있습니다. – BellevueBob