ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: filter: Windows backslashes in a properties file
Date Thu, 03 Apr 2003 07:04:27 GMT
Ah the wonders of dos^h^h^hnt^h^hwindows^h^h^h^h^h^h^hxp
In dos both / and \ are allowed for file separators. Most but
not all programs understand / as a file separator.

\ is used as an excape character for property files (and
for most normal usages).

If possible, I would use / in the properties file, in which case
one can use the <path> and <pathconvert> to convert \ to /.

<path id="basedir" path="${basedir}"/>
<pathconvert targetos="unix" refid="basedir" 
                   property="converted.basedir"/>
<echo message="converted ${converted.basedir}"/>

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

Peter.


On Thursday 03 April 2003 05:37, Elizabeth Cooper wrote:
> Use ${file.separator} in your properties file instead of the backslash. It
> will be converted correctly for any OS that uses this file.
>
> At 08:55 PM 4/2/2003, you 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?
> >
> >Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message