soo*_*yer 7 ant build-automation build
这就是我想要实现的目标:
如果设置了属性,则调用antcall target.这可行吗?谁能告诉我怎么样?
<condition>
<isset property="some.property">
<antcall target="do.something">
</isset>
</condition>
Run Code Online (Sandbox Code Playgroud)
这样的事情应该有效:
<if>
<isset property="some.property"/>
<then>
<antcall target="do.something"/>
</then>
</if>
Run Code Online (Sandbox Code Playgroud)
如果那时条件需要ant-contrib,那么在ant中有用的东西也是如此.
我知道我已经迟到了但是如果你使用的是ant-contrib,如果不支持嵌套的antcall元素(我使用的是antcontrib 1.02b,那么这里是另一种方法).
<target name="TaskUnderRightCondition" if="some.property">
...
</target>
Run Code Online (Sandbox Code Playgroud)
您可以进一步扩展它以检查是否应该在调用此目标之前设置some.property使用depends becuase depends在if属性被计算之前执行.因此你可以这样:
<target name="TestSomeValue">
<condition property="some.property">
<equals arg1="${someval}" arg2="${someOtherVal}" />
</condition>
</target>
<target name="TaskUnderRightCondition" if="some.property" depends="TestSomeValue">
...
</target>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,调用TestSomeValue,如果someval == someOtherVal,则设置some.property,最后,将执行TaskUnderRightCondition.如果someval!= someOtherVal,则会跳过TaskUnderRightCondition.
您可以通过文档了解有关条件的更多信息.
| 归档时间: |
|
| 查看次数: |
12617 次 |
| 最近记录: |