蚂蚁:EXEC任务有条件地设置ARG值 [英] Ant: conditionally set arg value of exec task

查看:141
本文介绍了蚂蚁:EXEC任务有条件地设置ARG值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Ant构建脚本,我应该修改。具体来说,我应该做一个颠覆结帐条件:目前只有树干被检出,如果需要的话,新版本应该签一个给定的分支

I've got an ant build script which I should modify. Specifically I should make a subversion checkout conditional: currently only the trunk gets checked out, the new version should checkout a given branch if needed.

<target name="do-svn-checkout" depends="init"
    <property name="branch" value=""/>
  <exec executable="svn">
    <arg value="checkout"/>
    <arg value="-r"/>
    <arg value="HEAD"/>
    <arg value="http://t01/java/trunk"/>
    <arg value="zzz"/>
    <arg value="--password"/>
    <arg value="xxx"/>
    <arg value="--username"/>
    <arg value="yyy"/>
  </exec>
</target>

属性分支将通过类似的命令行设置,例如 -Dbranch = mybranch

The property branch will be set via the command line like for instance -Dbranch=mybranch.

如果属性分支是空的,躯干应检查出来,但如果该属性为其他值,各个部门要进行检查的,如的http:// T01 / SVN / hlfg / HLFG / JAVA /分公司/最属性 - 值的-。因此,根据不同的属性SVN调用各自的ARG-值应进行修改。

If the property "branch" is empty, the trunk should be checked out, but if the property has any other value, the respective branch should be checked out, like http://t01/svn/hlfg/HLFG/java/branch/the-value-of-the-property. So depending on the property the respective arg-value of the svn call should be modified.

是否有可能与基本蚂蚁解决这个还是我需要使用内联脚本?

Is it possible to solve this with basic ant or would I need to use an inline script?

推荐答案

在使用Ant> = 1.9.3它是一块蛋糕用的新的,如果/除非功能使用Ant 1.9.1 介绍
(但你至少应该使用,因为在Ant中1.9.1的bug蚂蚁1.9.3,看到这个答案详细信息

When using Ant >= 1.9.3 it's a piece of cake with the new if/unless feature introduced with Ant 1.9.1 (but you should at least use Ant 1.9.3 because of bugs in Ant 1.9.1, see this answer for details)

不要忘了命名空间来激活该功能,F.E.

Don't forget the namespaces to activate that feature, f.e. :

<project
  xmlns:if="ant:if"
  xmlns:unless="ant:unless"
>

 <property name="foobar" value=" "/>

 <echo if:blank="${foobar}">foobar blank !</echo>
 <echo unless:blank="${foobar}">foobar not blank !</echo>

</project>

在你的情况是这样的:

<target name="do-svn-checkout" depends="init"
 <property name="branch" value=""/>
 <exec executable="svn">
   <arg value="checkout"/>
   <arg value="-r"/>
   <arg value="HEAD"/>
   <arg value="http://t01/java/trunk" if:blank="${branch}">
   <arg value=".." unless:blank="${branch}">
   <arg value="zzz"/>
   <arg value="--password"/>
   <arg value="xxx"/>
   <arg value="--username"/>
   <arg value="yyy"/>
 </exec>
</target>

这篇关于蚂蚁:EXEC任务有条件地设置ARG值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆