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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/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_Bnd - Fatal编程技术网

从ant路径中删除缺少的条目

从ant路径中删除缺少的条目,ant,bnd,Ant,Bnd,我遇到了一种情况,我们正在生成一个Ant,它可能包含一些实际上不存在的目录。不幸的是,这被输入到bnd,如果路径中缺少任何东西,它就会爆炸 所以我想要的是一种过滤的方法,只保留那些实际存在的路径元素 在Ant中有没有一个简单的方法来表达这一点,或者我必须写一个任务?我相信我已经找到了答案: <path id="bnd.cp.existing"> <restrict> <path refid="bnd.cp"/>

我遇到了一种情况,我们正在生成一个Ant
,它可能包含一些实际上不存在的目录。不幸的是,这被输入到
bnd
,如果路径中缺少任何东西,它就会爆炸

所以我想要的是一种过滤
的方法,只保留那些实际存在的路径元素


在Ant中有没有一个简单的方法来表达这一点,或者我必须写一个任务?

我相信我已经找到了答案:

    <path id="bnd.cp.existing">
        <restrict>
            <path refid="bnd.cp"/>
            <exists/>
        </restrict>
    </path>

    <!-- To see when it happens, add the following: -->
    <echo message="bnd classpath is: ${toString:bnd.cp.existing}"/>
    <iff>
        <not>
           <equals arg1="${toString:bnd.cp.existing}"
                   arg2="${toString:bnd.cp}"/>
        </not>
        <then>
           <echo message="    trimmed from: ${toString:bnd.cp}"/>
        </then>
    </iff>

restrict操作可以将一个类似路径的结构作为输入,并返回一个应用了请求过滤的版本——在这种情况下,只保留实际存在的路径元素。然后将其重新绑定到新ID,以供
操作使用