Reputation: 1211
I'd like to use a filterset to write out a file replacing a variable which is set as an ant property. I can pass the property if I have a nested filterset, but not a refid; I'm reusing the filterset, so I'd like to use the refid.
foo.old just contains foo=@foo@
This works:
<target name="filterset-test1"> <property name="bar" value="here is foo" /> <copy file="foo.old" tofile="foo.new1"> <filterset begintoken="@" endtoken="@"> <filter token="foo" value="${bar}" /> </filterset> </copy> </target>
And this fails to replace the token:
<filterset id="test-filters" begintoken="@" endtoken="@"> <filter token="foo" value="${bar}" /> </filterset> <target name="filterset-test3"> <property name="bar" value="property doesn't pass thru" /> <copy file="foo.old" tofile="foo.new3"> <filterset refid="test-filters" /> </copy> </target>
Is there a way to do the latter? I've also tried writing a properties file and using it as the filtersfile
property.
Upvotes: 3
Views: 2522
Reputation: 24194
The issue appears to be that inside the top-level filterset:
<filterset id="test-filters" begintoken="@" endtoken="@">
<filter token="foo" value="${bar}" />
</filterset>
The property bar
is undefined. Moving the property definition for bar
outside target filterset-test3
should work:
<?xml version="1.0" encoding="UTF-8" ?>
<project name="filter-test">
<property name="bar" value="property doesn't pass thru" />
<filterset id="test-filters" begintoken="@" endtoken="@">
<filter token="foo" value="${bar}" />
</filterset>
<target name="filterset-test3">
<copy file="foo.old" tofile="foo.new3">
<filterset refid="test-filters" />
</copy>
</target>
</project>
Upvotes: 4