Reputation: 4757
Trying to learn Phing, by converting Ant Build.xml to Phing. Can't seem to find a search function on Phing User doc....
This is what I have:
<condition property="script-suffix" value=".bat" else="">
<os family="windows" />
</condition>
<echo message="Script-suffix is ${script-suffix}" />
There are two problems that I need to fix but I don't know how:
I don't know how to convert this
condition into Phing acceptable. The
else=""
attribute is
causing an error.
I cannot access the
script-suffix
property
using ${script-suffix}
I've tried ${project.script-suffix}
, ${phing.script-suffix}
, $, and other obvious combination. And attempted to change the condition using the
tag and failed spectacularly T__T.<if>
, <else>
Thank you in advance ^__^.
Upvotes: 1
Views: 840
Reputation: 9636
This works for me:
<property name="script-suffix" value="" />
<condition property="script-suffix" value=".bat">
<os family="windows" />
</condition>
or
<condition property="script-suffix" value=".bat">
<os family="windows" />
</condition>
<condition property="script-suffix" value="">
<not>
<os family="windows" />
</not>
</condition>
For me your code returns (Phing 2.6.1)
BUILD FAILED
Error reading project file [wrapped: os (unknown) doesn't support the 'family' attribute.]
besides, I looks to me that you can't use <property />
task nested inside if
conditions.
Upvotes: 1
Reputation: 4757
<condition property="script-suffix" value=".bat">
<os family="windows" />
</condition>
<if>
<equals arg1="${script-suffix}" arg2=".bat" />
<then>
<os family="windows" />
</then>
<else>
<property name="script-suffix" value="" />
</else>
</if>
<echo message="---- Build Properties ----" />
<echo message="" />
<echo message="OS is ${os.name}" />
<echo message="Basedir is ${project.basedir}" />
<echo message="Script-suffix is ${script-suffix}" />
<echo message="" />
<echo message="---- Storefront Properties ----" />
Ah I think I got it, I don't have a window machine to test the window os option though. Thank you.
Upvotes: 1