ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charbel BITAR" <bita...@gmail.com>
Subject Re: Whichresource is URL-encoding spaces
Date Tue, 12 Feb 2008 23:36:39 GMT
Hi,

Is that what are you trying to do ?

<?xml version="1.0" encoding="utf-8"?>
<project name="test" basedir=".">
 <property environment="env" />
 <!-- Must set an environment variable named properties.file.url -->
 <!-- (Control Panel -> System -> Advanced -> Environment Variables) -->
 <available file="${env.properties.file.url}" property="exists" />
 <echo message="${env.properties.file.url}" />
 <fail message="it doesn't exist." unless="exists" />
 <target name="test" />
</project>

HTH
--
Charbel



On Feb 12, 2008 4:27 AM, Mike <senior_internet_dev@comcast.net> wrote:

> Hi, I'm relatively new with Ant but have been picking up on it. I trying
> to
> figure out why this Ant script doesn't complete successfully:
>
> """
> <?xml version="1.0" encoding="utf-8"?>
> <project name="test" basedir=".">
>        <property environment="env" />
>        <whichresource property="env.properties.file.url"
> resource="test.properties" classpath="."/>
>
>        <pathconvert property="env.properties.file">
>                <path location="${env.properties.file.url}" />
>                <regexpmapper to="\1" from="file:(.*)" />
>        </pathconvert>
>
>        <condition property="exists">
>                <available file="${env.properties.file}"/>
>        </condition>
>
>        <echo message="${env.properties.file}" />
>        <fail message="it doesn't exist." unless="exists" />
>
>        <target name="test" />
> </project>
> """
>
> The output I get from Eclipse is:
>
> """
> BUILD FAILED
> C:\Documents and Settings\Mike\workspace\test\build.xml:16: it doesn't
> exist.
> """
>
> I have determined that the cause is the whichresource task -- it's URL
> encoding spaces in my path to %20 this resulting in
> "C:\Documents%20and%20Settings\Mike". When I hard-code the same path
> without
> URL encoding the "exists" condition is true. Obviously one solution is to
> not use a path with spaces, but I'd like to keep it as-is if there's a
> workaround/fix.
>
> I haven't written this script, but if whichresource finds a file should
> there be a need to check if it's "available"?
>
> Thanks in advance for any help.
>
> Mike
>
>
> ---------------------------------------------------------------------
> 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