ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Buck, Robert" <>
Subject using <exec> to check for tool availability
Date Thu, 17 Jan 2008 15:20:29 GMT
I have a problem I am trying to solve that I need some help with. What
I'd like to do is check for the availability of an executable tool on
the system path. If the tool is available, then allow extra (secret
sauce) features to be enabled. Otherwise the extra (non-essential) build
features are disabled.
My thought was to use exec to determine if the tool exists. If someone
has a better way, please let me know.
So below you will see an attempt to use exec, and if it fails, set a
property, and check for that property down stream. Unfortunately I get
very bizzare results.
First, the state of the errorproperty makes no sense to me. Given the
following example, when dot is not available, the script says it is. I
would have thought that if there were an error, it would always be set.
Therefore other tasks should use the "unless" syntax. But the opposite
is true. This seems inconsistent with how the rest of Ant works. Try
this fragment out!
  <target name="check-for-dot">
    <exec executable="dot" failonerror="false"
failifexecutionfails="false" errorproperty="">
      <arg value="-help"/>

  <target name="do-dot" depends="check-for-dot"
    <echo message="dot is available"/>
> ant -f make-dot.xml
Buildfile: make-dot.xml
     [exec] Execute failed: CreateProcess: dot
-help error=2
     [echo] dot is available
This result makes no sense.
Second, notice that nasty little "Execute failed" stuff? I want to
supress it, but no matter what property I set in the exec task, the
output (or something similar) still comes screaming through. I know exec
may fail, I am doing this on purpose. So I want to tell ant to shut up
in this one case only. I would have thought that using the output and
error properties would help; they did not.
Does anyone have any better suggestions for how to check for tool
existence in Ant?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message