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
如何在ant构建脚本中拥有排除列表?_Ant_Build - Fatal编程技术网

如何在ant构建脚本中拥有排除列表?

如何在ant构建脚本中拥有排除列表?,ant,build,Ant,Build,我正在尝试向ant构建脚本添加一个排除列表。我有一个属性(我们称之为build.excludes),它看起来像这样: build.excludes=MyApp,AnotherApp 在我的构建脚本中,我有一个类似于以下内容的if语句: <for list="${appsList}" delimiter="" trim="true" param="currentApp" keepgoing="yes"> <sequential> <if>

我正在尝试向ant构建脚本添加一个排除列表。我有一个属性(我们称之为build.excludes),它看起来像这样:

build.excludes=MyApp,AnotherApp
在我的构建脚本中,我有一个类似于以下内容的if语句:

<for list="${appsList}" delimiter="" trim="true" param="currentApp" keepgoing="yes">
    <sequential>
        <if>
         <!-- check if my current build item is in the build.excludes list -->
            <then>
                <!-- build of a project happens here -->
            </then>
        </if>
    </sequential>
</for>

我能想到的唯一方法是使用for循环在build.excludes列表上迭代,然后执行某些操作(但我不知道将此for循环放在何处…可能放在宏中?)

谢谢


编辑:Ant 1.6.5,无法升级。

看起来您正在为任务使用
if
支持与ant任务相同的元素,ant任务已经存在了足够长的时间,可以在1.6.5版中使用

下面是一个例子:

<property name="build.excludes" value="MyApp,AnotherApp" />
<property name="appsList" value="MyApp,ExtraApp" />

<for list="${appsList}" delimiter="," trim="true" param="currentApp" keepgoing="yes">
    <sequential>
        <echo message="Checking @{currentApp}" />
        <if>
        <not>
            <contains string=",${build.excludes}," substring=",@{currentApp}," />
        </not>
        <then>
            <echo message="Building @{currentApp}" />
        </then>
        <else>
            <echo message="Not Building @{currentApp} - excluded" />
        </else>
        </if>
    </sequential>
</for>

通过使用一个宏并使用在宏中传递的var(ant contrib)来解决这个问题,然后将var设置为true或false。宏通过使用ant contrib中的for循环来执行比较。
 [echo] Checking MyApp
 [echo] Not Building MyApp - excluded
 [echo] Checking ExtraApp
 [echo] Building ExtraApp