You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Christian Cryder <ch...@enhydra.org> on 2001/09/07 21:25:15 UTC

Copy and Replace

I need to copy files into a new directory, and I'd like to perform a replace
on various string values they might contain in the process.

Since the Replace task is a fileset, I'm pretty sure I can pass that as an
argument to the copy task. However, will the copy occur without actually
changing the original files? Or does the replace happen on the original
files prior to the copy occuring?

To accomplish what I'm after, do I need to do it in two steps: copy, then
replace?

Thanks,
Christian
------------------------------------------------
Christian Cryder [christianc@enhydra.org]
Barracuda - MVC Component Framework for Webapps
http://barracuda.enhydra.org
------------------------------------------------
        "What a great time to be a Geek"


RE: Copy and Replace

Posted by Diane Holt <ho...@yahoo.com>.
--- Christian Cryder <ch...@enhydra.org> wrote:
> What I'm wondering is this: what if I have a different copy which needs
> to use different filters? Is there any way to set up the filters,
> perform the copy, and then remove the filters as soon as I'm done?

Don't think you can ever get rid of a filter, but you can reassign what
the filter value should be. Eg:

  <target name="copy">
    <filter token="foo" value="bar"/>
    <copy file="foo" tofile="bar" filtering="yes"/>
    <filter token="foo" value="baz"/>
    <copy file="foo" tofile="baz" filtering="yes"/>
  </target>

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

RE: Copy and Replace

Posted by Christian Cryder <ch...@enhydra.org>.
Looking at the documentation on filtering, I see the following example:

  <filter token="year" value="2000"/>
  <copy todir="${dest.dir}" filtering="true">
    <fileset dir="${src.dir}"/>
  </copy>

What I'm wondering is this: what if I have a different copy which needs to
use different filters? Is there any way to set up the filters, perform the
copy, and then remove the filters as soon as I'm done?

Thanks,
Christian
------------------------------------------------
Christian Cryder [christianc@enhydra.org]
Barracuda - MVC Component Framework for Webapps
http://barracuda.enhydra.org
------------------------------------------------
        "What a great time to be a Geek"


> -----Original Message-----
> From: Erik Hatcher [mailto:erikhatcher@earthlink.net]
> Sent: Friday, September 07, 2001 2:04 PM
> To: ant-user@jakarta.apache.org
> Subject: Re: Copy and Replace
>
>
> You can do a copy/replace in one step without affecting the original file
> like this:
>
>         <copy file="web.xml" filtering="true" todir="${build.dir}"/>
>
> Use the <filter> task to set up the replacement strings and tokenize your
> source file with the appropriate format (see the <filter> and <copy>
> documentation for more details).
>
> ----- Original Message -----
> From: "Christian Cryder" <ch...@enhydra.org>
> To: "Ant-User" <an...@jakarta.apache.org>
> Sent: Friday, September 07, 2001 12:25 PM
> Subject: Copy and Replace
>
>
> > I need to copy files into a new directory, and I'd like to perform a
> replace
> > on various string values they might contain in the process.
> >
> > Since the Replace task is a fileset, I'm pretty sure I can pass
> that as an
> > argument to the copy task. However, will the copy occur without actually
> > changing the original files? Or does the replace happen on the original
> > files prior to the copy occuring?
> >
> > To accomplish what I'm after, do I need to do it in two steps:
> copy, then
> > replace?
> >
> > Thanks,
> > Christian
> > ------------------------------------------------
> > Christian Cryder [christianc@enhydra.org]
> > Barracuda - MVC Component Framework for Webapps
> > http://barracuda.enhydra.org
> > ------------------------------------------------
> >         "What a great time to be a Geek"
> >
>


Re: Copy and Replace

Posted by Erik Hatcher <er...@earthlink.net>.
You can do a copy/replace in one step without affecting the original file
like this:

        <copy file="web.xml" filtering="true" todir="${build.dir}"/>

Use the <filter> task to set up the replacement strings and tokenize your
source file with the appropriate format (see the <filter> and <copy>
documentation for more details).

----- Original Message -----
From: "Christian Cryder" <ch...@enhydra.org>
To: "Ant-User" <an...@jakarta.apache.org>
Sent: Friday, September 07, 2001 12:25 PM
Subject: Copy and Replace


> I need to copy files into a new directory, and I'd like to perform a
replace
> on various string values they might contain in the process.
>
> Since the Replace task is a fileset, I'm pretty sure I can pass that as an
> argument to the copy task. However, will the copy occur without actually
> changing the original files? Or does the replace happen on the original
> files prior to the copy occuring?
>
> To accomplish what I'm after, do I need to do it in two steps: copy, then
> replace?
>
> Thanks,
> Christian
> ------------------------------------------------
> Christian Cryder [christianc@enhydra.org]
> Barracuda - MVC Component Framework for Webapps
> http://barracuda.enhydra.org
> ------------------------------------------------
>         "What a great time to be a Geek"
>


Re: Copy and Replace

Posted by Erik Hatcher <er...@earthlink.net>.
Sorry for the duplication... I guess Diane and I are playing dueling helpers
today!   She won this one, and I think I beat her to the zero-file length
answer!  :)

    Erik


----- Original Message -----
From: "Diane Holt" <ho...@yahoo.com>
To: <an...@jakarta.apache.org>
Sent: Friday, September 07, 2001 12:55 PM
Subject: Re: Copy and Replace


> <replace> is used to change a file in-place; use <filter> + <copy> with
> filtering="on" to modify a file during a copy.
>
> Diane
>
> --- Christian Cryder <ch...@enhydra.org> wrote:
> > I need to copy files into a new directory, and I'd like to perform a
> > replace
> > on various string values they might contain in the process.
> >
> > Since the Replace task is a fileset, I'm pretty sure I can pass that as
> > an
> > argument to the copy task. However, will the copy occur without actually
> > changing the original files? Or does the replace happen on the original
> > files prior to the copy occuring?
> >
> > To accomplish what I'm after, do I need to do it in two steps: copy,
> > then
> > replace?
> >
> > Thanks,
> > Christian
> > ------------------------------------------------
> > Christian Cryder [christianc@enhydra.org]
> > Barracuda - MVC Component Framework for Webapps
> > http://barracuda.enhydra.org
> > ------------------------------------------------
> >         "What a great time to be a Geek"
> >
>
>
> =====
> (holtdl@yahoo.com)
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo!
Messenger
> http://im.yahoo.com


Re: Copy and Replace

Posted by Diane Holt <ho...@yahoo.com>.
<replace> is used to change a file in-place; use <filter> + <copy> with
filtering="on" to modify a file during a copy.

Diane

--- Christian Cryder <ch...@enhydra.org> wrote:
> I need to copy files into a new directory, and I'd like to perform a
> replace
> on various string values they might contain in the process.
> 
> Since the Replace task is a fileset, I'm pretty sure I can pass that as
> an
> argument to the copy task. However, will the copy occur without actually
> changing the original files? Or does the replace happen on the original
> files prior to the copy occuring?
> 
> To accomplish what I'm after, do I need to do it in two steps: copy,
> then
> replace?
> 
> Thanks,
> Christian
> ------------------------------------------------
> Christian Cryder [christianc@enhydra.org]
> Barracuda - MVC Component Framework for Webapps
> http://barracuda.enhydra.org
> ------------------------------------------------
>         "What a great time to be a Geek"
> 


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com