You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by John Lindwall <JL...@Xifin.com> on 2003/04/03 05:55:40 UTC

filter: Windows backslashes in a properties file

My build.xml is copying a properties file and using a filterset to perform substitutions during the copy.

    <copy file="${src.test.dir}/templates/LorTest.properties" todir="${build.test.dir}" filtering="yes">
      <filterset>
        <filter token="LOR_HOME" value="${basedir}"/>
      </filterset>
    </copy>

On our Windows development machines ${basedir} is generally "D:\Lor".   The resulting file is properly substituted such that any occurrence of "@LOR_HOME@" is replaced with "D:\Lor".  

The output file is a properties file and when we load the properties at runtime this string is transformed to "D:Lor" -- note the missing backslash.  The resulting path is no good since it lacks that initial backslash.

Is there some way to handle this issue nicely?

Thanks!

Re: filter: Windows backslashes in a properties file

Posted by Steve Loughran <st...@iseran.com>.
Denis N. Antonioli wrote:
> 


 >--
 >SCSI is *NOT* magic. There are *fundamental technical reasons* why it
 >is necessary to sacrifice a young goat to your SCSI chain now and then.
 >  -- John Woods

I like this .signature.

we had a project that wasnt working, and my proposed solution was 'find 
a virgin and have him sacrifice a goat'...the reason for having the 
virgin do it was that if the goat didnt work, we had an immediate 
escalation strategy.

-steve


Re: filter: Windows backslashes in a properties file

Posted by "Denis N. Antonioli" <an...@ifi.unizh.ch>.
On Jeudi, avr 3, 2003, at 05:55 Europe/Zurich, John Lindwall wrote:

> My build.xml is copying a properties file and using a filterset to 
> perform substitutions during the copy.
>
>     <copy file="${src.test.dir}/templates/LorTest.properties" 
> todir="${build.test.dir}" filtering="yes">
>       <filterset>
>         <filter token="LOR_HOME" value="${basedir}"/>
>       </filterset>
>     </copy>
>
> On our Windows development machines ${basedir} is generally "D:\Lor".  
>  The resulting file is properly substituted such that any occurrence 
> of "@LOR_HOME@" is replaced with "D:\Lor".
>
> The output file is a properties file and when we load the properties 
> at runtime this string is transformed to "D:Lor" -- note the missing 
> backslash.  The resulting path is no good since it lacks that initial 
> backslash.
>
> Is there some way to handle this issue nicely?


There are two solutions:
1) '\' is an escape character, so write it twice, as: "D:\\Lor"
2) use the unix separator '/', it works on NT too "`D:/Lor"


Best
	dna

-- 
SCSI is *NOT* magic. There are *fundamental technical reasons* why it
is necessary to sacrifice a young goat to your SCSI chain now and then.
   -- John Woods