ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbmdharris <>
Subject Inserting different relative paths into multiple files using the same token
Date Sun, 09 Nov 2008 21:49:59 GMT

I have many different HTML files in different directories.  I'm already using
the <copy> task with a <filterset> to replace tokens in these files.  I'm
trying to figure out how to create a token like @ROOTPATH@ that will always
resolve to the proper number of "../" patterns to get from the current
directory to the root of the directory tree.  This would be used for
example, like this:

&lt;a href="@ROOTPATH@/foo/bar.html"&gt;some link&lt;/a&gt;

In a file that then gets included into lots of other files in lots of
different directories.  So the value of @ROOTPATH@ needs to be different
depending upon the directory in which file containing it is located.  I am
unable to use absolute directory paths because this HTML is only read off of
a user's local disk instead of a webserver and an absolute path beginning at
the user's C: drive (or / if on Unix) isn't acceptable.  My ant build tasks
use <replaceregexp> to simulate SSI <!--#include --> to get the contents of
these files (like the banner) into all the other files.

I've tried using this:
<for param="currentDir">
      <dirset dir="${rootPath}"/>
      <propertyregex property="currentDirForwardSlashes"
input="@{currentDir}" regexp="\\" replace="/" defaultvalue="@{currentDir}"
      <echo message="Path: ${currentDirForwardSlashes}"/>

But the path always comes back fully-qualified and I can't figure out how to
truncate the ${rootPath} poriton of the path off the front of the path and
then change the remaining directories in the path to ".."

I've also tried using a recursive technique with <dirset includes="*"> so I
only get one level at a time and then recursively call my task appending
"../" to a parameter.  However, I'm getting an error that <antcall> can't
call tasks recursively.

Does anyone have any ideas?
View this message in context:
Sent from the Ant - Users mailing list archive at

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

View raw message