0
Ant 스크립트가 실패 할 곳이 있습니다.속성이 존재하더라도 Ant는 실패하지 않습니다.
특성 파일 :
application.foo.name=foo
application.foo.path=[path-to-foo]
application.foo.file=foo.jar
appName=
코드 :
<target name="deploy_app" description="Deploys app">
<condition property="appSelected">
<and>
<not>
<equals arg1="${appName}" arg2="" />
</not>
<isset property="${appName}" />
</and>
</condition>
<if>
<equals arg1="${appSelected}" arg2="true" />
<then>
<!-- do nothing! -->
</then>
<else>
<input
message="Please enter application name:"
addproperty="newAppName"
/>
<var name="appName" value="${newAppName}" />
</else>
</if>
<antcall inheritAll="true" target="deploy" />
</target>
<target name="deploy">
<echo message="Deploying from property: application.${appName}.file" />
<propertycopy silent="true" name="appFile" from="application.${appName}.file" />
<propertycopy silent="true" name="appPath" from="application.${appName}.path" />
<echo message="appFile: ${appFile}" />
<fail unless="${appFile}" message="appfile: ${appFile} No application with the name ${appName} is defined in your properties file." />
</target>
출력 :
[echo] Deploying from property: application.foo.file
[echo] appFile: foo.jar
ERROR: The following error occurred while executing this line:
appfile: foo.jar No application with the name foo is defined in your properties file.
그것은 심지어 속성 값을 인쇄,하지만 존재하지 않는 줄 알아!
이유가 무엇입니까?
그것은 주목해야한다 그 "만약"과 "propertycopy"작업 개미의 contrib라는 제 3 자 ANT 확장의 일부입니다. –
여기에서 배포 호출 : –