2017-05-17 9 views
0

내 개미 대상 중 하나의 논리를 속성 원본에 따라 변경하고 싶습니다. Ant 타겟의 초기화는 속성 파일을 가져 오지만, 속성을 덮어 쓰고 싶을 때 명령 행에서 지정합니다. 개미 대상이 속성이 초기 속성 파일에서 나온 것인지 아니면 명령 줄에서 나온 것인지 여부를 알 수 있습니까?Apache ant target은 명령 줄에서 속성이 무시되었는지 여부를 감지 할 수 있습니까?

등록 정보 파일 경우 속성 "my.property"가 다음 명령 줄을 보여줍니다

ant -buildfile buildthis.xml my.target.to.call -Dmy.property=overridesfilevalue 

는 "my.target.to.call"여부에 따라 논리를 감지하고 정의 할 수있을 것입니다 "my.property"가 명령 행에서 전달 되었습니까?

답변

2

Ant는 속성이 설정되는지 여부를 확인하는 isset 조건을가집니다. 특성 파일을로드하기 전에이 조건을 간단히 실행 한 다음 빌드 논리를 결과에 기초 할 수 있습니다.

예 :

<condition property="property.override.detected"> 
    <isset property="property.to.override" /> 
</condition> 

<property file="build.properties" /> 

<target name="do-this-if-the-property-was-overridden" if="property.override.detected"> 
    ... 
</target> 

<target name="do-this-if-the-property-was-not-overridden" unless="property.override.detected"> 
    ... 
</target> 

<target 
    name="default" 
    depends=" 
     do-this-if-the-property-was-overridden, 
     do-this-if-the-property-was-not-overridden" 
/> 
+0

브릴리언트! 나는 내일 그것을 시도 할 것이다. 도와 주셔서 감사합니다! – okorng

+0

제안대로 작업했습니다. 다시 한번 감사드립니다. – okorng