O great Ant gurus :-) I seek a clean way to perform operating-system dependent operations with a fail-safe check in case the O/S isn't supported. Is there already an idiom out there for this?
Here's what I have come up with so far: <target name="projecthelp" description="Usage"> <condition property="projecthelp_target" value="projecthelp_unix"> <os family="unix"/> </condition> <condition property="projecthelp_target" value="projecthelp_windows"> <os family="windows"/> </condition> <condition property="projecthelp_target" value="projecthelp_fail"> <not> <or> <os family="unix"/> <os family="windows"/> </or> </not> </condition> <antcall target="${projecthelp_target}"/> </target> <target name="projecthelp_unix"> <exec dir="${ant_loc}" taskname="" executable="ant" os="Linux"> <arg line="-projecthelp"/> </exec> </target> <target name="projecthelp_windows"> <exec dir="${ant_loc}" taskname="" executable="cmd.exe" os="Windows 2000"> <arg line="/c ant -projecthelp"/> </exec> </target> <target name="projecthelp_fail"> <fail message="The projecthelp target is not yet configured for this O/S"/> </target> I don't like the replication of the O/S names (unix and windows) in the above. I'm strongly opposed to needless redundancy, and really wish I could avoid it here. FYI, we use the above in our "Queen Ant" script to encapsulate using the -projecthelp output of Ant as the default "target" when Ant is invoked (i.e. no target -> usage). Calling scripts look like this: <?xml version="1.0"?> <project name="common" default="projecthelp"> : <target name="projecthelp"> <ant antfile="${QUEEN_ANT}" target="projecthelp"> <property name="ant_loc" value="${my_dir}"/> </ant> </target> : I'm particularly interested in better ways to do the first snippet above WITHOUT the O/S name repetition. But I'm open to comments, suggestions, ideas, etc. about either excerpt. Thanks! Extra Credit: Anyone know why <exec> and <condition> use two different sets of names for O/Ses? I know THAT they do; I'm curious about WHY... -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>