請看看:
http://ant.apache.org/manual/Tasks/symlink.html
我不有一臺Linux機器現在來測試,但我想,隨着這樣的事情:
<symlink action="record" linkfilename="my.links">
<fileset dir="${my.folder}" includes="*"/>
</symlink>
你應該能夠將您的符號鏈接記錄到一個文件,然後按照您的意願處理的文件。例如,你可以創建一個只有「符號鏈接」文件的列表,並遍歷它來做你想做的事情。
編輯:
對於這個解決方案,你需要安裝ant-contrib。只需將ant-contrib-1.0b3.jar解壓到您的ant/lib目錄即可。然後使用以下build.xml文件:
<project name="test" default="build">
<!--Needed for antcontrib-->
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<target name="build">
<property name="my.dir" value="/home/stefanos"/>
<exec executable="bash" outputproperty="symlinks" dir="${my.dir}">
<arg value="-c"/>
<arg value="\ls -1 | xargs -l readlink"/>
</exec>
<foreach list="${symlinks}" delimiter="${line.separator}" param="link" target="process.link"/>
</target>
<target name="process.link">
<!--Do whatever you want with the file targeted by the symlink-->
<echo message="Processing link : ${link}"/>
</target>
</project>
訣竅是linux命令,它從符號鏈接返回所有目標文件。然後,您只需使用foreach任務遍歷它們,然後調用一個目標,在該目標中可以根據需要隨文件執行任何操作。
什麼是您的操作系統? – FailedDev
Linux,但更改爲Ant(來自Make),因爲我也想在Windows 7上構建。 –