ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neil Benn <neil.b...@gmail.com>
Subject Re: ReplaceRegExp with windows filenames
Date Wed, 24 Aug 2005 21:19:04 GMT
Hello,

         Thanks for the tip - however it still does the same thing -
it seems like the backslashes are simply being ignored (if there is
one or two).  I'll make some further investigations - if anyone has
ideas as to what could be going on here - I;d appreciate any pointers.

    One thing I thought of is loading the filei into a property, using
the propertyregex on the property to replace and writing the file back
out from the property.  However I can;t find a task to write a
property into a file (ant property write {of variation thereof} -
gives back the wrong things) - does anyone know of one?

Here's the verbose output I get :

init:
 [property] Loading C:\Documents and Settings\Neil Benn\.ant.properties

replace_inf_paths:
     [echo] C:\Documents and Settings\Neil Benn\My Documents\svnfiles\trunk\Drop
Paq
     [echo] C:\\Documents and Settings\\Neil Benn\\My Documents\\svnfiles\\trunk
\\DropPaq
[replaceregexp] Replacing pattern 'C\:\\.*\\DropPaq' with 'C:\\Documents and Set
tings\\Neil Benn\\My Documents\\svnfiles\\trunk\\DropPaq' in 'C:\Documents and S
ettings\Neil Benn\My Documents\svnfiles\trunk\DropPaq\installer\CE\DropPaq.inf'
by line.
[replaceregexp] File has changed; saving the updated file

    Thanks.

Cheers,

Neil

On 8/23/05, Andrew Goktepe <andrewgoktepe@gmail.com> wrote:
> Assuming that having double backslashes in the basedir would solve your
> problem, you could use the propertyregex task from ant-contrib to use a
> second property with that substitution:
>  <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> ...
> <propertyregex property="basedir.escaped" input="${basedir}" regexp="\\"
> replace="\\\\\\\\" global="true"/>
> <replaceregexp file="${basedir}/installer/CE/DropPaq.inf"
> match="C\:\\.*\\DropPaq"
> replace="${basedir.escaped}"
> byline="true"/>
>  Yes, there are 8 backslashes in the 'replace' attribute value. That is how
> many I needed to end up with 2 backslashes in the replaced string when I
> tested this.
>  -Andrew
>  On 8/22/05, Neil Benn <neil.benn@gmail.com> wrote:
> >
> > Hello,
> >
> > I need to make an ant task which will go into a file, look
> > for a pattern and replace it with the contents of the ${basedir}
> > variable.
> >
> > I have the following xml to do this:
> >
> > <target name="replace_inf_paths" depends="init">
> > <replaceregexp file="${basedir}/installer/CE/DropPaq.inf"
> > match="C\:\\.*\\DropPaq"
> > replace="${basedir}"
> > byline="true"/>
> > </target>
> >
> > The target text is :
> >
> > 1 = ,"DropPaqEtc",,"C:\Documents and Settings\Neil Benn\My
> > Documents\svnfiles\trunk\DropPaq\DropPaq\installer\CE" ; The etc
> > directopry which contains all image and the jar file
> > 2 = ,"CremeLib",,"C:\Documents and Settings\Neil Benn\My
> > Documents\svnfiles\trunk\DropPaq\installer\CE\Creme\lib" ; Contains
> > all required creme lib files
> > 3 = ,"CremeBin",,"C:\Documents and Settings\Neil Benn\My
> > Documents\svnfiles\trunk\DropPaq\installer\CE\Creme\bin" ; Contains
> > all required creme bin file
> > 4 = ,"DropPaqSave",,"C:\Documents and Settings\Neil Benn\My
> > Documents\svnfiles\DropPaq\savefiles" ; References the save files
> > 5 = ,"DropPaqLib",,"C:\Documents and Settings\Neil Benn\My
> > Documents\svnfiles\trunk\DropPaq\lib" ; The lib directory
> > 6 = ,"Bin",,"C:\Documents and Settings\Neil Benn\My
> > Documents\svnfiles\trunk\DropPaq\installer\CE" ; Te bin directory for
> > this app
> >
> > So when I run this, it finds the text but does this :
> >
> > 1 = ,"DropPaqEtc",,"C:Documents and SettingsNeil BennMy
> > DocumentssvnfilestrunkDropPaq\installer\CE" ; The etc directopry
> > which contains all image and the jar file
> > 2 = ,"CremeLib",,"C:Documents and SettingsNeil BennMy
> > DocumentssvnfilestrunkDropPaq\installer\CE\Creme\lib" ; Contains all
> > required creme lib files
> > 3 = ,"CremeBin",,"C:Documents and SettingsNeil BennMy
> > DocumentssvnfilestrunkDropPaq\installer\CE\Creme\bin" ; Contains all
> > required creme bin file
> > 4 = ,"DropPaqSave",,"C:Documents and SettingsNeil BennMy
> > DocumentssvnfilestrunkDropPaq\savefiles" ; References the save files
> > 5 = ,"DropPaqLib",,"C:Documents and SettingsNeil BennMy
> > DocumentssvnfilestrunkDropPaq\lib" ; The lib directory
> > 6 = ,"Bin",,"C:Documents and SettingsNeil BennMy
> > DocumentssvnfilestrunkDropPaq\installer\CE" ; Te bin directory for
> > this app
> >
> > As you can see, I've lost the backslashes which means that the
> > filenames are no longer valid. Is there a way I can get round this -
> > I can't put two backslashes in basedir. The file is a windows file
> > (used to make a cab file for a pda) so I need windows filesname.
> >
> > Does anyone know a way to get round this?
> >
> > Any and all help greatly appreciated.
> >
> > Cheers,
> >
> > Neil
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> 
>

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


Mime
View raw message