ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike" <senior_internet_...@comcast.net>
Subject Whichresource is URL-encoding spaces
Date Tue, 12 Feb 2008 03:27:49 GMT
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
View raw message