ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Goktepe <andrewgokt...@gmail.com>
Subject Re: ReplaceRegExp with windows filenames
Date Mon, 22 Aug 2005 22:03:23 GMT
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
> 
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message