ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike" <senior_internet_...@comcast.net>
Subject RE: Whichresource is URL-encoding spaces
Date Tue, 12 Feb 2008 23:46:18 GMT
Hi Charbel,

env.properties.file.url is actually getting defined in my Ant script by the
"whichresource" task. After that task completes, env.properties.file.url
contains the value "C:\Documents%20and%20Settings\Mike".

But I think the "available" task fails because of the "%20" space encoding
(whichresource returns URL-encoded paths). If I manually define
env.properties.file.url to "C:\Documents and Settings\Mike" everything is
OK. But this is not desirable as the script must be able to determine a path
to a file dynamically.

Mike

-----Original Message-----
From: Charbel BITAR [mailto:bitarch@gmail.com] 
Sent: Tuesday, February 12, 2008 6:37 PM
To: Ant Users List
Subject: Re: Whichresource is URL-encoding spaces

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
>
>


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


Mime
View raw message