ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <qazw...@gmail.com>
Subject Re: Rename directories in Ant
Date Wed, 13 Jun 2007 13:25:35 GMT
There's a slight problem in that the java.util.regex.Pattern class
used by Ant doesn't support what in Perl would be the "g" flag. That
Java class is the java.util.regex.Matcher and I don't know how the
regexmapper would call this particular class.

You might have to run this multiple times until no more moves are
done. If you use the antcontrib <trycatch> and set "failonerror" in
the move, you could keep looping until the property is set on the
catch.

That's the only thing I can think of.

On 6/13/07, Cesar Martinez Izquierdo <cesar.martinez@iver.es> wrote:
> Qazwart wrote:
> > What version of Ant are you using? You seem to take the hard way:
> >
> > If you're using at least version 1.3, you can simply do this:
> >
> > <move file="/tmp/myDir/test/hello/search"
> >     todir="/tmp/myDir/test/hello/search_"/>
> >
> > If it's earlier than version 1.3:
> >
> > <move todir="/tmp/myDir/test/hello/search_">
> >    <fileset dir="/tmp/myDir/test/hello/search"/>
> > </move>
> >
> > No need to use a mapper or anything:
> >
> > BTW, the problem you're running into is that regex is naturally greedy,
> > so it always takes the biggest chunk it can to make the match. Since you
> > can easily define the directory using simpler globbing expressions, you
> > could have use that. Or, you can use the "Reluctant" qualifier which
> > will only take the very first match it can find:
> >
> > This: <regexpmapper from="(.*?)(${oldValue})(.*)" to="\1${newValue}\3"
> > Instead of: <regexpmapper from="(.*)(${oldValue})(.*)" to="\1${newValue}\3"
> >
>
> Hi Qazwart, thanks for your reply.
> The problem is that I don't want to rename ONE directory, but ALL the
> "search" directories in a directory tree.
> And the "search" directory may be located inside another "search"
> directory, so getting the very first match is not enough... I need all
> of them to be replaced...
> I guess it needs to be performed using a totally different strategy. Any
> idea?
>
> --
> César Martínez Izquierdo
> Equipo de desarrollo gvSIG
> http://www.gvsig.gva.es
>
> IVER T.I.
> C/ Salamanca 50
> 46005 Valencia - Spain
> http://www.iver.es
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
--
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