Noel Yap
Noel Yap

Reputation: 19788

How to convert Ant property into Ant resource?

I would like to convert something like:

<property name='aoeu' value='a,o,e,u'/>

to:

<path id='ueoa'>
    <pathelement location="a/file"/>
    <pathelement location="o/file"/>
    <pathelement location="e/file"/>
    <pathelement location="u/file"/>
</path>

The value of aoeu could contain any number of comma-separated elements.

I can use the groovy Ant task, but not anything from ant-contrib.

So far, I have the following:

<groovy>
    properties['aoeu'].tokenize(',').each() {
        properties["ueoa-${it}"] = "${it}/file"
    }
</groovy>

<propertyset id='ueoa'>
    <propertyref prefix='ueoa-'/>
</propertyset>

which creates ueoa as:

ueoa=ueoa-a=a/file, ueoa-o=o/file, ueoa-e=e/file, ueoa-u=u/file

when what I really want is something like:

ueoa=/path/to/a/file:/path/to/o/file:/path/to/e/file:/path/to/u/file

How can I get this conversion to work? Alternatively, how do I create a resource in the groovy Ant task?

Upvotes: 2

Views: 339

Answers (1)

Noel Yap
Noel Yap

Reputation: 19788

The following worked:

<groovy>
    ant.path(id:'ueoa') {
        properties['aoeu'].tokenize(',').each() {
            pathelement(location:"${it}/file")
        }
    }
</groovy>

Upvotes: 3

Related Questions