What happen if someone run Ant symlink task on Windows (NTFS)?

五迷三道 提交于 2019-12-12 11:26:54

问题


I write ant build script. I need to create a symlink and I found symlink task. According to manual, it works only on Unix. What happens if someone run my build script on windows platform? Will build fail? Or this task will be ignored on windows platform? Or in case of NTFS drive, it will even work?


回答1:


I'm running Win7 and I tried it. Since I have Mingw installed it used ln. Ln seemed just to copy everything. Since a normal Windows installation does not have ln, it would fail there.

Here's what happens without ln:

C:\Users\Janus\Desktop>.\apache-ant-1.8.2\bin\ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
Buildfile: C:\Users\Janus\Desktop\build.xml

dist:

BUILD FAILED
C:\Users\Janus\Desktop\build.xml:3: Could not launch ln: java.io.IOException: Cannot run program "ln": CreateProcess error=2, The system can
not find the file specified

Total time: 1 second

C:\Users\Janus\Desktop>

Build.xml:

<project name="MyProject" default="dist" basedir=".">
<target name="dist">
<symlink link="lol" resource="d3dwindower" />
</target>
</project>



回答2:


I created a condition property to identify if I am running on unix:

<condition property="isUnix">
  <os family="unix"/>
</condition>

and then use an 'if' attribute on my target so it will only execute if on unix:

<target name="makeSymLinkToJar" depends="jar" if="isUnix">
    <symlink link="${distlink.jar}" resource="${dist.jar}"/>
</target>


来源:https://stackoverflow.com/questions/6962089/what-happen-if-someone-run-ant-symlink-task-on-windows-ntfs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!