Hi, just posting a follow-up in hopes of someone being able to help.. Thanks in advance.
Mike -----Original Message----- From: Mike [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 12, 2008 6:46 PM To: 'Ant Users List' Subject: RE: Whichresource is URL-encoding spaces 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:[EMAIL PROTECTED] 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] For additional > commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
