ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <qazw...@gmail.com>
Subject Re: Replace string in file
Date Tue, 13 May 2008 17:26:36 GMT
What type of replacement? You can do a filter on strings like
@VERSION@, @DATE@, @FOO@, or whatever you want via filtersets and
mappers when you copy. For example, I have some configuration files.
They're called *.properties.template, and I replace the @xxx@ strings
with values from a deploy.properties file and remove the *.template
suffix. The filterset replaces the @xxx@ tokens with the correct
values while the mapper renames the file by removing the *.template
suffix:

        <!-- Copy the configuration files that don't contain tokens -->
        <copy todir="${local.jboss.home}/server/${jboss.instance}"
            verbose="${copy.verbose.flag}">
            <fileset dir="${jboss.install.home}/jbdev1">
                <exclude name="**/*.template"/>
            </fileset>
        </copy>

        <!-- Copy the configurable files and replace any tokens -->
        <copy todir="${local.jboss.home}/server/${jboss.instance}"
            overwrite="true"
            verbose="${copy.verbose.flag}">
            <fileset dir="${jboss.install.home}/jbdev1">
                <include name="**/*.template"/>
            </fileset>
            <mapper type="glob"
                from="*.template" to="*"/>
            <filterset begintoken="@" endtoken="@">
                <filter token="path_to_server_dir"
                    value="${local.jboss.home}/server/${jboss.instance}"/>
                <filtersfile file="${deploy.properties.file}"/>
            </filterset>
        </copy>

Is this what you're looking for?

On Mon, May 12, 2008 at 9:18 AM, Guy Catz <Guy.catz@waves.com> wrote:
> hey guys,
>
>  Is it possible to replace a string in an existing file?
>
>  Thanks,
>     Guy.
>



-- 
--
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message