I need a symbolic link selector in Apache Ant.
The following selectors are available to the Core.
Can anyone advise me on writing a <scriptselector> for selecting only the symbolic linked files under a directory? Or any other way?
The reason:
folder
|-- file-0.0.1
|-- file-0.0.2
|-- file-0.0.3
`-- file --> file-0.0.3
I just want to get the file that is symbolically linked by file. In this case file-0.0.3, but the symbolic link can change and I don’t want all the other files to be in the Ant <fileset>
Please take a look at :
http://ant.apache.org/manual/Tasks/symlink.html
I don’t have a linux machine to test now but I guess that with the something like this :
You should be able to record your symlinks into a file and then processing the files as you wish. For example you could then create a list only with the “symlinked” files and iterate over it to do what you want.
EDIT :
For this solution you will need to install the ant-contrib. Just unpack the ant-contrib-1.0b3.jar to your ant/lib directory. Then use the following build.xml file :
The trick is the linux command which returns all the targeted files from the symlinks. Then you just iterate through them with the foreach task and you call a target in which you can do whatever you need with the files.