ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: How to check availability of an executable?
Date Mon, 25 Feb 2002 12:07:31 GMT
On Mon, 25 Feb 2002, Otto Perdeck <otto.perdeck@xs4all.nl> wrote:

> I need to check whether certain executables are available in my Ant
> build script. Depending on availability, parts of the build would be
> executed or not.

You can use <available> using the file attribute for the name of the
executable and the filepath attribute set to the value of the PATH
environment variable.

untested:

<property environment="env" />
<condition property="foo-command-present">
  <or>
    <available file="foo" filepath="${env.PATH}" />
    <!-- special case for Windows, may be PATH or Path -->
    <available file="foo.exe" filepath="${env.Path}" />
    <available file="foo.exe" filepath="${env.PATH}" />
  </or>
</condition>

Stefan

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message