The symlink task (http://ant.apache.org/manual/OptionalTasks/symlink.html)
can be used to create symbolic links with relative paths on a per-file
basis:
<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"/>
<targetfile/>
<fileset dir="../dir_a">
<include name="*.xml"/>
</fileset>
<arg value="."/>
<mapper type="glob" from="*" to="../../dir_a/*" />
</apply>
This is assuming you have a dir structure like this, which is inferred by
your code:
dir_a/
*.xml files
somedir/
build.xml
dir_b/
-Andrew
On 11/5/07, yvesforkl <[EMAIL PROTECTED] > 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:
> http://www.nabble.com/Creating-SymLinks-with-relative-paths-tf4751944.html#a13587787
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>