Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于条件的antcall_Ant_Build_Build Automation - Fatal编程技术网

基于条件的antcall

基于条件的antcall,ant,build,build-automation,Ant,Build,Build Automation,这就是我努力实现的目标: 如果设置了属性,则调用antcall目标。这可行吗?有人能告诉我怎么做吗 <condition> <isset property="some.property"> <antcall target="do.something"> </isset> </condition> 类似的方法应该可以: <if> <isset property="some.pro

这就是我努力实现的目标:

如果设置了属性,则调用antcall目标。这可行吗?有人能告诉我怎么做吗

<condition>
    <isset property="some.property">
        <antcall target="do.something">
    </isset>
</condition>

类似的方法应该可以:

<if>
    <isset property="some.property"/>
    <then>
        <antcall target="do.something"/>
    </then>
</if>


,但在ant中几乎任何有用的东西都是如此。

还可以考虑调用groovy以实现以下目的:

<use-groovy/>
<groovy>
   if (Boolean.valueOf(properties["some.property"])) {
     ant.project.executeTarget("do.something")
   }
</groovy>

if(Boolean.valueOf(properties[“some.property”])){
ant.project.executeTarget(“do.something”)
}

我知道我做这件事真的很晚了,但如果您使用的是ant-contrib的,而if不支持嵌套的antcall元素(我使用的是antcontrib 1.02b,它不支持)


...
您可以进一步展开它,检查是否应该在使用depends调用此目标之前设置some.property,因为在计算if属性之前执行depends。因此,你可以这样:

<target name="TestSomeValue">
  <condition property="some.property">
    <equals arg1="${someval}" arg2="${someOtherVal}" />
  </condition>
</target>

<target name="TaskUnderRightCondition" if="some.property" depends="TestSomeValue">
  ...
</target>

...
在本例中,调用TestSomeValue,如果someval==someOtherVal,则设置some.property,最后执行TaskUnderRightCondition。如果某个地方someOtherVal然后将跳过TaskUnderRightCondition


您可以通过了解更多有关条件的信息。

太好了。对我有用。我对Ant Contrib很满意。它应该是可以复制的。你能做一些像
?@siledh我不知道。我不这么认为。
<target name="TestSomeValue">
  <condition property="some.property">
    <equals arg1="${someval}" arg2="${someOtherVal}" />
  </condition>
</target>

<target name="TaskUnderRightCondition" if="some.property" depends="TestSomeValue">
  ...
</target>