2010-08-02 23 views
1

试图通过将Ant Build.xml转换为Phing来学习Phing。似乎无法找到Phing用户文档搜索功能....Phing:访问<condition>中的值属性标记

这是我有:

<condition property="script-suffix" value=".bat" else=""> 
<os family="windows" /> 
</condition> 

<echo message="Script-suffix is ${script-suffix}" /> 

有我需要解决两个问题,但我不知道如何:

  1. 我不知道如何将这种 条件转化为Phing可以接受的。 else=""属性是 导致错误。

  2. ${script-suffix}

我试过${project.script-suffix}${phing.script-suffix}$, and other obvious combination. And attempted to change the condition using the <if>,<其他>标签和壮观失败T__T我无法通过访问 script-suffix财产 。

预先感谢您^ __ ^。

回答

1
<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 ----" /> 

啊我想我知道了,我没有一个窗口机器来测试窗口os选项,但是。谢谢。

1

这个工作对我来说:

<property name="script-suffix" value="" /> 
<condition property="script-suffix" value=".bat"> 
    <os family="windows" /> 
</condition> 

<condition property="script-suffix" value=".bat"> 
    <os family="windows" /> 
</condition> 
<condition property="script-suffix" value=""> 
    <not> 
     <os family="windows" /> 
    </not> 
</condition> 

对我来说,你的代码返回(Phing 2.6.1)

BUILD FAILED 
Error reading project file [wrapped: os (unknown) doesn't support the 'family' attribute.] 

之外,我看来,我认为你不能使用嵌套在if条件中的<property />任务。

+0

我也从蚂蚁工作生成文件转换为Phing和你的第一个建议完美工作,谢谢 – Carlton 2014-01-13 12:39:10