提升Ant build文件灵活性的方法(2)
有时候我们需要面对不同操作系统平台的部署和构建,比如在windows和unix平台下,我们可以分别编写两个build文件,不过更为灵活的作法是,利用ant的<os>,然后在target中加上if属性,这样就可以实现仅用一个build文件实现多平台的构建了:
<condition property="os.windows">
<os family="windows"/>
</condition>
<condition property="os.unix">
<os family="unix"/>
</condition>
<target name="..." if="os.windows">
... ...
</target>
<target name="..." if="os.unix">
... ...
</target>
BTW:看了anthillpro的build.xml,未免让人觉得有些遗憾,看起来作者是过分依赖<antcall>了,这是有悖于ant的精神的。
