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

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

问题描述

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

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

似乎应该有一种方法可以用 来做到这一点,但对我来说它是什么并不明显.建议?

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 的问题在于没有定义目录的顺序.要保留原始列表的顺序,请使用 filelist 代替 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}" />

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

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