Reputation: 1608
Im using the replace task to replace a token in my html pages but it only appears to be replacing the token in 1 file and skipping the rest.
<replace dir="${basedir}" token="@CDN" value=""${cdnUrl}"">
<include name="*.html"/>
</replace>
Any ideas why its only replacing this value in one of the html files in this directory?
Upvotes: 0
Views: 387
Reputation: 107040
Maybe you should do something like this?
<replace dir="${basedir}" token="@CDN" value=""${cdnUrl}"">
<include name="**/*.html"/>
</replace>
It's hard to say. Are the other HTML files in the directory or subdirectories?
I discourage my developers to use <replace>
because you end up replacing files that are checked into the source control system. The developers commit their changes, and the files that were modified with <replace>
end up getting updated with the parameters gone. We usually end up with multiple commits as developers try to untangle the mess (which usually gets caught in production deployments).
I recommend to copy the files, and use <filterset>
and <filter>
to do the replacement:
<mkdir dir="${basedir}/target"/> <!-- Or whatever you call your build directory -->
<copy todir="${basedir}/target">
<fileset dir="${basedir}">
<include name="**/*.html"/>
</fileset>
<filterset prefix="@" suffix="@">
<filter token="CDN"
value=""${cdnUrl}""/>
</filterset>
</copy>
This copies your HTML files into the target
directory (which is the build directory). When the developer runs the clean
target, it merely deletes that target
directory.
Upvotes: 1