在Phing早期结束目标

时间:2016-06-20 11:01:25

标签: build phing

我正在尝试修改Phing脚本,但无法看到我认为是一个明显的功能。

Phing脚本具有通用&#39;确认&#39;在各个执行阶段检查输入的目标。我想自动化脚本,以便它可以在没有输入的情况下运行。我希望能够通过在目标中插入某种<break><end>类型的任务来使其尽早返回。 manual似乎没有列出此类功能。

我知道我可以通过创建一个中间目标来检查cmd行参数然后调用确认目标,但是有更优雅的方法吗?

这是需要自动化的目标,并且是从多个地方调用的。跳过的触发器是通过cmd line -D。

设置的属性
 <!-- confirm a user action -->
<target name="confirm">
    <input propertyname="confirm" validargs="yes,no">
        ${confirm.message} ('yes' to continue)
    </input>
    <if>
        <not>
            <equals arg1="${confirm}" arg2="yes" />
        </not>
        <then>
            <fail message="You didn't say 'yes'" />
        </then>
    </if>
</target>

1 个答案:

答案 0 :(得分:1)

出于同样的目的,我使用这种技术:

<if>
  <not>
    <isset property="confirm" />
  </not>
  <then>
    <input propertyname="confirm" validargs="yes,no">
        ${confirm.message} ('yes' to continue)
    </input>
    <if>
        <not>
            <equals arg1="${confirm}" arg2="yes" />
        </not>
        <then>
            <fail message="You didn't say 'yes'" />
        </then>
    </if>
  </then>
</if>

然后你可以执行

phing build.xml -Dconfirm=yes

没有承诺。

相关问题