ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject AW: AW: How to build an Ant path from a comma-seperated list?
Date Thu, 20 Nov 2008 12:51:10 GMT
Not a one liner but a two-liner.
This is the technique I use often for displaying paths with <pathconvert> ...

    <pathconvert property="p" pathsep="${line.separator}- ">
        <fileset dir="." includes="*"/>
    <property name="listing" value="- ${p}${line.separator}"/>

The main task just calculates the middle part (${p}) and I have to put something before and
after it.

In your case this is the same:

    <property name="list" value="aaa,bbb,ccc"/>
    <property name="pattern" value="**/${pattern.internal}/"/>
    <echo>Input List   : '${list}'</echo>
    <echo>Input Pattern: '${pattern}'</echo>


>-----Urspr√ľngliche Nachricht-----
>Von: snoofkin [] 
>Gesendet: Mittwoch, 19. November 2008 20:39
>Betreff: Re: AW: How to build an Ant path from a comma-seperated list?
>Thanks for this idea!
>The problem is that the input list is of unknown size, and I 
>could not find
>a regexp that will convert all items in this list correctly (I 
>bet this can
>be done).
>So I came up with the following solution using <for>, <var> and
>    <var name="dependencies.path" value="" />
>    <property name="input.list" value="aaa,bbb,ccc" />
>    <target name="calculate-dependencies-path" 
>description="Converts the
>input.list comma-seperated list to dependencies.path">
>        <for param="item" list="${input.list}">
>            <sequential>
>                <propertyregex property="item.path"
>                        override="true"
>                        input="@{item}"
>                        regexp="(.+)"
>                        replace="**/\1\/"
>                        casesensitive="false"/>
>                <var name="dependencies.path"
>value="${dependencies.path},${item.path}" />
>            </sequential>
>        </for>
>        <echo>RESULT: ${dependencies.path}</echo>
>    </target>
>This prints
>    RESULT: ,**/aaa/,**/bbb/,**/ccc/
>If there is an easier solution using one line regexp I would 
>gladly use it,
>as this is somewhat cumbersome.
>View this message in context: 
>Sent from the Ant - Users mailing list archive at
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message