ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: fail-safe O/S-dependent operations idiom?
Date Thu, 18 Jul 2002 22:48:04 GMT
Sure, that's a good way to run an os-specific command I guess, but to get an
help or using target to use the built-in -project of Ant (which seems to be
the ultimate goal here), simply do (as posted a few weeks ago, with output
for Ant 1.4.1 and 1.5beta):

  <target name="usage">
    <java classname="">
      <arg value="-projecthelp" />
      <arg value="-buildfile" />
      <arg value="${ant.file}" />

And Diane, I'm not sure I follow the link between <condition> and
<propertyset>? --DD

-----Original Message-----
From: Diane Holt [] 
Sent: Thursday, July 18, 2002 5:19 PM
To: Ant Users List
Subject: Re: fail-safe O/S-dependent operations idiom?

--- Mike Cepek <> wrote:
> 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?

  <target name="setArgs" description="Set up projecthelp args">
    <condition property="antcmd" value="ant">
      <os family="unix"/>
    <condition property="antcmd.args" value="-projecthelp">
      <os family="unix"/>
    <condition property="antcmd" value="cmd.exe">
      <os family="windows"/>
    <condition property="antcmd.args" value="/c ant -projecthelp">
      <os family="windows"/>
    <fail unless="antcmd"
          message="Projecthelp target not yet configured for this OS."/>

  <target name="projecthelp" depends="setArgs" description="Print usage">
    <exec dir="${ant_loc}" executable="${antcmd}">
      <arg line="${antcmd.args}"/>

>             <property name="ant_loc" value="${my_dir}"/>

When setting locations, you should use the 'location' attribute.

> I'm particularly interested in better ways to do the first snippet above
> WITHOUT the O/S name repetition.

Unfortunately, <condition> only sets one property (maybe something for
Dominique to consider for his <propertyset> addition?), so there is still
a bit of redundancy, but hopefully it's a bit cleaner than what you had.

> 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...

I don't think they do -- not for 'name', anyway. (You're welcome to prove
me wrong, though.)



Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message