I have been using XCode to start a Java application, what I had not realised is that the build.xml created for ant relise on files from the Mac base install, ie it will not build correctly on any other OS which completely voids the point of writing in a portable language.
Below should be an example of an ant file that can do OS specific things.
<project name="OS-check-with-if-switch" default="chkOS">
<!-- affects global scope -->
<property file="build.global.properties" />
<target name="chkOS" description="if switch to set OS specivic settings">
<condition property="isMac">
<os family="mac" />
</condition>
<condition property="isUnix">
<and>
<os family="unix" />
<not>
<os family="mac" />
</not>
</and>
</condition>
<condition property="isWindows">
<os family="windows" />
</condition>
<antcall target="setMacEnv" />
<antcall target="setUnixEnv" />
<antcall target="setWindowsEnv" />
</target>
<target name="setUnixEnv" if="isUnix">
<echo>This is an Unix machine.</echo>
<!-- affects local scope only -->
<property file="unix.properties" />
</target>
<target name="setMacEnv" if="isMac">
<echo>This is an Mac machine.</echo>
<!-- affects local scope only -->
<property file="mac.properties" />
</target>
<target name="setWindowsEnv" if="isWindows">
<echo>This is a Windows machine.</echo>
<!-- affects local scope only -->
<property file="windows.properties" />
</target>
</project>
Twitter Updates
Wednesday, 14 January 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment