ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Burton" <>
Subject Re: conditional if statement
Date Fri, 16 Mar 2001 05:01:44 GMT
Hello Alan,

You will have to write a task to do this or, you could set a property when
Ant starts up that would accomplish the same thing.

Assuming Ant 1.3, create a batch file antrc_pre.bat with something like
the following contents:
    if "%OS%" == "Windows_NT" set ANT_OPTS=%ANT_OPTS%
    if not "%OS%" == "Windows_NT" set ANT_OPTS=%ANT_OPTS%

Put the antrc_pre.bat in the directory pointed to by the %HOME% enviroment
variable (assumes Windows NT/2000).  The ant.bat script will run
antrc_pre.bat every time it starts up.  Anything in %ANT_OPTS% will be
passed to Ant on the command line.

If you are using Ant 1.3, you could use the environment attribute of the
<property> task to load the environment into Ant.  Then you could check
for the presense of a Windows specific variable like COMSPEC using,
if="env.COMSPEC" or unless="env.COMSPEC".  This would be fine if you don't
care about NT/2000 vs. 9x versions.

These are all hacks that may or may not work for you.  A task is still the
cleanest way to go and would not depend on any startup settings being
present to get the desired behavior.

-Bill wrote:
> Hello,
> Could you tell me if there is a way to execute a target, such that ${}!="Windows
NT"? The current if statement in a target can only be used if a property has been set, however,
it does not allow the evaluation of a statment.
>                    Thanks,
>                           Alan
> Laters,
>         Alan

View raw message