0
我有一個螞蟻腳本失敗,它不應該。螞蟻'失敗,除非'失敗即使屬性存在
屬性文件:
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第三方ANT擴展的一部分。 – 2014-11-24 20:52:47
這裏調用deploy: –
2014-11-24 23:25:10