我想转换如下内容:
<property name='aoeu' value='a,o,e,u'/>
至:
<path id='ueoa'>
<pathelement location="a/file"/>
<pathelement location="o/file"/>
<pathelement location="e/file"/>
<pathelement location="u/file"/>
</path>
aoeu 的值可以包含任意数量的逗号分隔元素。
我可以使用 groovy Ant 任务,但不能使用 ant-contrib 中的任何任务。
到目前为止,我有以下内容:
<groovy>
properties['aoeu'].tokenize(',').each() {
properties["ueoa-${it}"] = "${it}/file"
}
</groovy>
<propertyset id='ueoa'>
<propertyref prefix='ueoa-'/>
</propertyset>
将 ueoa 创建为:
ueoa=ueoa-a=a/file, ueoa-o=o/file, ueoa-e=e/file, ueoa-u=u/file
当我真正想要的是:
ueoa=/path/to/a/file:/path/to/o/file:/path/to/e/file:/path/to/u/file
如何才能实现此转换?或者,如何在 groovy Ant 任务中创建资源?
最佳答案
以下工作有效:
<groovy>
ant.path(id:'ueoa') {
properties['aoeu'].tokenize(',').each() {
pathelement(location:"${it}/file")
}
}
</groovy>
关于ant - 如何将Ant属性转换为Ant资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9796763/