ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hempe <>
Subject OS detection: am I missing the obvious?
Date Wed, 08 Nov 2000 03:55:13 GMT
Forgive me if I'm missing the obvious, but: 

How do I detect what OS I am running under in Ant?  Yes, I know about the
property "", but it doesn't seem like Ant allows you to test the
*content* of this (or any other) property for purposes of branching
behavior--only whether or not the property is set.  

I've been trying contortions like:
  <touch file=".build_OS_is_${}"/>
  <available file=".build_OS_is_Windows NT"
  <available file=".build_OS_is_SunOS"

But this doesn't work because Available checking is obviously being done
before the touch, must be a "special" task from Ant's runtime point of view,
perhaps because it wants to know all property values before executing tasks.

Of course, the OS-indicating file is there the *next* time you run Ant, but
this is so ugly I figured I'd just punt and ask.  I know that "exec" has an
"os" attribute but others don't.  I want to do the seemingly-obvious:

<target name="OSDependentTarget" if="My_OS_is_UNIX">

I know I could force the user to specify their OS in a property file, but
Ant's Java runtime already knows. . .I just am not sure how to branch based
on that knowledge. 

--John Hempe

View raw message