ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yvesforkl <>
Subject Re: Creating SymLinks with relative paths
Date Tue, 06 Nov 2007 09:50:00 GMT

Andrew Goktepe wrote:
> The symlink task (
> can be used to create symbolic links with relative paths on a per-file
> basis [...]

Thank you for this hint, once again I see that most of what needs to be done
is fairly easy with ant. I wonder why I didn't simply search for "symlink"
at ...

But even if I had found the symlink task, I would never have been able to
come up with the solution below which is what I need, as I have set of files
which I can't pass to the symlink task. (It's a pity that ant does have to
do without true loops, but I know that this is one of its strengths.)

Andrew Goktepe wrote:
> If that doesn't work and you need to continue down the <apply> path you
> could try something like this [...]

That works like a charm for creating relative symbolic links (with constant
paths) to several files in one go. Thank you very much for this perfect

Andrew Goktepe wrote:
> This is assuming you have a dir structure like this, which is inferred by
> your code [...]

Sorry for not having exposed my directory structure more clearly.

While my original problem is now solved, I also need to create symlinks to a
set of files in another setting. In this case, the path to the resources
needs to be dynamic. My directory layout is as follows (given as full paths
to prevent indentation trouble):


With ${basedir} set to either of the version-number subdirectories of a, b,
or c, I would like to create relative symlinks within top/build that point
to all files matching *.txt and *.xml in ${basedir}/data (the file names
will never collide). This means that I have to extract the names of the 2
directories immediately above "data" to establish the symlink path.

I tried with the following code modeled after your example, but the links
are not created and I didn't notice any error:

<apply executable="ln"
  <arg value="-sf"/>
  <fileset dir="data">
    <include name="*.xml"/>
    <include name="*.txt"/>
  <arg value="."/>
  <mapper type="regexp"

Do you have an idea how I could make this work? Maybe the other way round,
i.e. looking for the resources from the target directory's point of view? 


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