蚂蚁:转换为路径相对路径的逗号分隔的列表 [英] Ant: Convert comma-delimited list of relative paths to path

查看:131
本文介绍了蚂蚁:转换为路径相对路径的逗号分隔的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个逗号分隔的目录列表:

I have a comma-delimited list of directories:

foo,bar,baz,qux

我想将它转化为含有(像)以下的Ant路径:

I want to convert it to an Ant path containing (something like) the following:

${basedir}/build/foo/classes
${basedir}/build/bar/classes
${basedir}/build/baz/classes
${basedir}/build/qux/classes

好像应该有一种用&LT做到这一点; pathconvert> ,但它并不明显,我会是怎样。建议?

It seems like there should be a way to do this with <pathconvert>, but it's not obvious to me what it would be. Suggestions?

推荐答案

您可能能够使用的 dirset 握住你的目录列表,然后反馈到这pathconvert。是这样的:

You might be able to use a dirset to hold your list of directories, then feed that into pathconvert. Something like:

<property name="dirs" value="foo,bar,baz,qux" />
<dirset id="dir_list" dir="${basedir}" includes="${dirs}" />

<pathconvert refid="dir_list" property="dirs_prop">
    <regexpmapper from="(${basedir})/(.*)" to="\1/build/\2/classes" />
</pathconvert>

则属性 $ {dirs_prop} 将持有你想...或几乎路径。与 dirset 的问题是,目录顺序没有定义。要保留原始列表的顺序,使用 文件清单: 到位的 dirlist

Then the property ${dirs_prop} will hold the path you want... or almost. The problem with dirset is that the order of directories is not defined. To retain the order of the original list, use a filelist in place of the dirlist:

<filelist id="dir_list" dir="${basedir}" files="${dirs}" />

这篇关于蚂蚁:转换为路径相对路径的逗号分隔的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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