ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Goktepe" <>
Subject Re: Creating SymLinks with relative paths
Date Mon, 05 Nov 2007 15:30:03 GMT
The symlink task (
can be used to create symbolic links with relative paths on a per-file

<symlink link="dir_b/mylink" resource="../dir_a/myfile" />

The value given for the resource attribute is relative to the location of
the link you are creating (same behavior as command-line usage of ln).
Perhaps you can build upon this to create the set of links you need.

If that doesn't work and you need to continue down the <apply> path you
could try something like this, using relative=true, addsourcefile=false, and
a glob mapper to create relative paths for the matching files.

<apply executable="ln" dir="dir_b" relative="true" addsourcefile="false">
  <arg value="-sf"/>
  <fileset dir="../dir_a">
    <include name="*.xml"/>
  <arg value="."/>
  <mapper type="glob" from="*" to="../../dir_a/*" />

This is assuming you have a dir structure like this, which is inferred by
your code:

    *.xml files


On 11/5/07, yvesforkl < > wrote:
> Creating SymLinks with relative paths shouldn't be too hard for ant.
> However,
> I can't figure out the right way to do it.
> Using bash commands, I'd do
> cd dir_b
> ln -s ../../dir_a/*.xml .
> yielding symbolic links within dir_b that look like ../../dir_a/file1.xml
> etc.
> What is the equivalent of this in ant? I have only managed to get absolute
> paths with the code below (while the "relative" attribute will just link
> file1.xml to file1.xml without any relative path) :
> <apply executable="ln"
>   dir="dir_b">
>   <arg value="-sf"/>
>   <srcfile/>
>   <fileset dir="../../dir_a">
>     <include name="*.xml"/>
>   </fileset>
>   <arg value="."/>
>   <mapper type="identity"/>
> </apply>
> As I have fixed paths here, I considered putting the call to "ln" into a
> single <exec>, but then how to change the working directory first?
>   Yves
> --
> View this message in context:
> Sent from the Ant - Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message