0
votes

I'm trying to create an ant build target that supports var substitution dynamically.

<target name="replace_property" depends="init_ant_contrib">
    <propertyregex input="${replace_inboundproperty"
        property="${replace_outboundproperty}"
        regex="${replace_match}"
        replace="${replace_target}"
        global="true"
        override="true" />
</target>

so I load the properties file and i'm basically setting the vars as such:

replace_inboundproperty="/target/path/targetfile"
replace_outboundproperty=blah
replace_match="/target/(.*)/targetfile"
replace_target="\1"

so when I echo blah, I'm getting "1". Now if I actually do this:

<target name="replace_property" depends="init_ant_contrib">
    <propertyregex input="${replace_inboundproperty"
        property="${replace_outboundproperty}"
        regex="${replace_match}"
        replace="\1"
        global="true"
        override="true" />
</target>

and echo blah, I'll get "path".

Can anyone tell me what I'm missing to allow the replace to use capture groups from a properties file / ant -D? Using ant-contrib 1.0b3.

Thanks!

1

1 Answers

0
votes

Found out that in the properties file, if you double escape it, it'll function correctly:

replace_target=\\1