2013-03-01 1 views
4

NAnt 0.92에서 속성을 정의하고이를 검사 한 직후에 속성을 정의합니다. 그것은 존재하지 않지만 호출 된 타겟에 존재합니다. 버그 또는 기능입니까?!? 나는 문서를 검색하지만 그것에 대한 언급을 찾을 수 없었다.새로 정의 된 속성이있는 NAnt property :: exists()?

<target name="test"> 
    <property name="testprop" value="test value" /> 

    <echo message="property value = ${testprop}" /> 

    <if test="${property::exists(testprop)}"> 
    <echo message="property exists, as it should!" /> 
    </if> 

    <if test="${not property::exists(testprop)}"> 
    <echo message="property doesn't exists... WTF?" /> 
    </if> 

    <call target="test2" /> 
</target> 

<target name="test2"> 
    <echo message="property value in sub-target = ${testprop}" /> 
</target> 

출력 :

시험 :

[echo] property value = test value 
[echo] property doesn't exists... WTF? 

TEST2 :

[echo] property value in sub-target = test value 

답변

5

속성의 이름은 property::exists에 전화에서 인용 될 필요가있다. 그래서 그것입니다

<if test="${not property::exists('testprop')}"> 
    <echo message="property doesn't exists... WTF?" /> 
    <!-- don't swear --> 
</if> 

업데이트 : 귀하의 예제에서 어떤 일이 발생 하는가? 인용 부호가없는 속성 testprop은 함수 property::exists에 대한 호출에서 값으로 대체됩니다. 따라서 사실 프로빙 속성 test value (BTW는 유효한 속성 이름이 아닙니다)입니다. 이 체크 아웃 :

<target name="test"> 
    <property name="test.value" value="foo" /> 
    <property name="testprop" value="test.value" /> 
    <echo message="property value = ${testprop}" /> 
    <if test="${property::exists(testprop)}"> 
    <echo message="property exists, as it should!" /> 
    </if> 
    <if test="${not property::exists(testprop)}"> 
    <echo message="property doesn't exists... WTF?" /> 
    </if> 
</target> 

출력 :

[echo] property value = test.value 
[echo] property exists, as it should! 
+0

LOL OH! 나는 이미 그것을 알고 있었다! 가끔은 바보 같은 실수를 지적 할 누군가가 필요할 때가 있습니다. 감사! – dstj

+0

정의되지 않은 속성을 참조하는 동작은 무엇입니까? ''는 오류로 끝나거나 빈 문자열입니까? – jxramos

+0

은 정의되지 않은 속성을 참조 할 수 없습니다. '속성 평가에 실패했습니다. 표현식 :이 속성이 존재하지 않습니다 $ {gibberishXYZ} "속성 '$ {gibberishXYZ'이 (가) 설정되지 않았습니다. – jxramos

관련 문제