1

尝试通过将 Ant Build.xml 转换为 Phing 来学习 Phing。似乎在 Phing User doc 上找不到搜索功能......

这就是我所拥有的:

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

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

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

  1. 我不知道如何将此条件转换为可接受的 Phing。该 else=""属性导致错误。

  2. 我无法 script-suffix使用${script-suffix}

我试过${project.script-suffix}, ${phing.script-suffix},标记并失败了 T__T。$, and other obvious combination. And attempted to change the condition using the <if>, <else>

提前谢谢你^__^。

4

2 回答 2

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.]

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

于 2013-12-04T11:19:38.470 回答
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 ----" />

啊,我想我明白了,不过我没有窗口机器来测试窗口操作系统选项。谢谢你。

于 2010-08-02T17:11:05.480 回答