gpt4 book ai didi

ant - 如何将 Ant 属性转换为 Ant 资源?

转载 作者:行者123 更新时间:2023-12-04 05:53:27 24 4
gpt4 key购买 nike

我想转换如下:

<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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com