ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Rosenberg">
Subject RE: Problem with Ant pathconvert and paths with spaces
Date Fri, 23 Jul 2010 14:43:17 GMT
What happens if you run the build outside of Eclipse?

Jonathan Rosenberg
Founder & Executive Director, Tabby's Place

-----Original Message-----
From: Bailey, Darragh [] 
Sent: Friday, July 23, 2010 9:51 AM
To: Ant Users List
Subject: Problem with Ant pathconvert and paths with spaces

I've been trying to run my ant builds within eclipse and I've been running
into a slight problem with the path generated by the pathconvert task.

After some testing, it seems that it's a problem in general with spaces
appear in paths.

The project that I have needs to pick up a library from another project in
my tree, until such time that I have everything converted to publish and
retrive artifacts from ivy, I've been using whichresource & pathconvert to
assist in locating the library from another project in my tree.

Here's a snippet of the ant tasks I'm using:
<whichresource property="extra.lib.url" class="${extralib.classname}">
    <fileset dir="${extra.lib.dir}" >
      <include name="**/*.jar" />
<fail unless="extra.lib.url" message="Extra library required not found" />
<pathconvert property="extra.lib">
  <path location="${extra.lib.url}" />
  <regexpmapper to="\1" from="file:([^\!]*)" />

<echo message="Using extra lib from ${extra.lib}" />
<path id="">
  <fileset file="${extra.lib}" />

I reference in the classpath that I construct for the
javac task.

When running the Ant build on linux, I normally don't have spaces in the
directory names, so everything worked fine until I tried to enable Ant
builds within eclipse. My workspace directory resides under "C:\Documents
and Settings\<my username>\My Documents\workspace".

So when I build I get the following error:
"C:\Documents and Settings\<my username>\My Documents\workspace\<some
project>\build.xml:201: C:\Documents%20and%20Settings\<my
username>\My%20Documents\workspace\extralib\build not found."

Some testing on the linux, by moving extralib to extralib\ test and setting
the property extra.lib.dir on the command line as following, resulted in a
similar error message:
-Dextra.lib.dir=/build/extralib\ test/trunk

"/build/<some project>/trunk/build.xml:209:
/build/extralib%20test/trunk/build does not exist."

The echo line in the ant code above prints the following output:
"Using common lib from
So I know that the whichresource part is locating the file, and the
pathconvert is striping the "jar:file:" from the start and the 
"!${extralib.classname}" text from the end.

The problems seems to be due to the space getting converted to "%20" by
whichresource, and I don't seem to be able to match it to change it back.

Besides changing the workspace directory to c:\workspace\ and asking all the
other developers that are working on the project to do the same, is there
anything I can do to change how I'm using pathconvert to avoid this problem?

Searching the mail archives it seems someone else ran into the same issue
back in Feb 2008:

But the only solution suggested was to effectively require the property
being set, to be set to the exact path required in the first place and thus
not use whichresource at all. Is that the only alternative? (besides writing
an extension)

Darragh Bailey

Systems Software Engineer
Hewlett Packard Galway Ltd.

Postal Address:    Hewlett Packard Galway Limited, Ballybrit Business Park,
Registered Office: Hewlett Packard Galway Limited, 63-74 Sir John Rogerson's
Quay Dublin 2
Registered Number: 361933 

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message